I have used Orchard Localization in my asp.net core application.
Startup.cs
services.AddPortableObjectLocalization(options => options.ResourcesPath = "Resources");
services
.AddMvc()
.AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix)
.AddDataAnnotationsLocalization();
model.cs
[Display(Name = "First Name")]
[Required(ErrorMessage = "Customer first name required")]
public string CustomerFirstName { get; set; }
en.po (contains English translations)
msgid "Customer first name required"
msgstr "Customer first name required"
no.po (contains Norwegian translation)
msgid "Customer first name required"
msgstr "Fornavn mangler"
Request url for english
Home/HomeRequest/?cid=40&culture=en
Request url for norwegian
Home/HomeRequest/?cid=11&culture=no
I first entered english url and checked the required validation, validation for english localization fired perfectly. Then I changed value of cid and culture to norwegian and checked the validation validation fires with english localization not in norwegian.
How to get the data annotation validation according to the locale?