How to localize data annotation and validation error messages in ASP.NET CORE 3.1
[Required(ErrorMessage = "something")]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)]
[DataType(DataType.Password)]
[Display(Name = "Password")]
public string Password { get; set; }
I use the standard implementation of resource files from the Microsoft documentation
services.AddLocalization(option => option.ResourcesPath = ProjectConstants.LanguageResourcesPath);
services.AddControllersWithViews()
.AddViewLocalization(
LanguageViewLocationExpanderFormat.Suffix,
option => option.ResourcesPath = "Resources")
.AddDataAnnotationsLocalization();
My Resource Files structure
|-Resoures
|---Controllers
|---Views
|---Models
I am refactoring Identity Pages and can not showing standard error messages in two languages. This example in Microsoft docs does not work for me.. [https://docs.microsoft.com/en-us/aspnet/core/fundamentals/localization?view=aspnetcore-3.1#dataannotations-localization] Please someone help me
Debuginappsettings.Development.jsonand check the log when you submit the form. - Ryan