in registration form when user enter just numeric character it shows "password must have at least one lowercase ['a'-'z']", I need to translate it in my native language, where can I find this message?
-
Possible duplicate of [How to localize ASP.NET Identity UserName and Password error messages?](http://stackoverflow.com/questions/19961648/how-to-localize-asp-net-identity-username-and-password-error-messages) – iAM Apr 22 '17 at 07:42
2 Answers
Firstly, install the identity localized package in Package Manager Console:
Install-Package Microsoft.AspNet.Identity.Core.tr
(.tr or your localization code .it, .es, .de, .fr etc.)
Then set culture in web.config:
<system.web>
<globalization culture="tr-TR" uiCulture="tr"/>
</system.web>
Now, your identity messages will be automatically set according to your language.

- 2,790
- 1
- 30
- 33
These messages are provided by framework, not from your model, so you cannot use data annotations for this. But you can solve the problem in another way:
Step 1: Create resource file for your controller or use shared resource. For example, if your controller is /Controllers/AccountController.cs, then resource file should be Controllers.AccountController.de.resx in your resources folder (depending on configuration; instead of de use your locale code).
Step 2: Write translations for strings: PasswordRequiresLower, PasswordRequiresNonAlphanumeric, PasswordRequiresUpper. These strings are codes of identity errors. You can see them during debug of registration process after failed registration.
Step 3: Do not forget to use localizer in your controller
using Microsoft.Extensions.Localization;
public class AccountController : Controller
{
private readonly IStringLocalizer<AccountController> _localizer;
public AccountController(IStringLocalizer<AccountController> localizer)
{
_localizer = localizer;
}
// Another code of AccountController class.
}
Step 4: Add translated descriptions for errors in registration action
var result = await _userManager.CreateAsync(user, model.Password);
if (result.Succeeded)
{
// User account created.
return RedirectToAction("Index", "Home");
}
// User account creation failed.
foreach (var error in result.Errors)
{
ModelState.AddModelError(error.Code, _localizer[error.Code]);
}

- 33
- 9