I rephrase another question I asked earlier.
I have a basic C # Asp.net MVC 5 application. I create an account through the following code (provided by the template in version 2013)
protected async Task<bool> CreateAccountAndAddRoleAsync(UserManager<ApplicationUser> userManager, ApplicationUser user, string password, string role)
{
var result = await userManager.CreateAsync(user, password);
if (result.Succeeded)
{
try
{
var roleResult = await userManager.AddToRoleAsync(user.Id, role);
if (roleResult.Succeeded)
{
return true;
}
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
}
AddErrors(result);
return false;
}
protected void AddErrors(IdentityResult result)
{
foreach (var error in result.Errors)
{
ModelState.AddModelError("", error);
}
}
The problem is that when the username is already accepted (or any other error message), the messages are in English. For instance,
Name xxx already done
Instead
L'identifiant xxx est déjà utilisé
The problem is that the message is provided by the framework using
var result = wait userManager.CreateAsync (user, password);
And AddErrors(result);lists the messages (in English) to display them to the user. How to change messages?
I changed the culture in the webconfig file with
<globalization uiCulture="fr-FR" culture="fr-FR" />
. , , , , .
- , , IdentityResult?