How can I globally overload error messages getting ,for example, from [Required] attribute? Probably, I should change CultureInfo, but I can't find any tutorials. Language still English as default. Thank you!
A first reference on globalization and localization of ASP.NET Core is https://docs.asp.net/en/latest/fundamentals/localization.html.
There you'll find information about how to translate data annotations and how to configure ASP.NET Core to select the appropriate language / CultureInfo
for each request.
DataAnnotations error messages are localized with
IStringLocalizer<T>
. Using the option ResourcesPath = "Resources", the error messages in RegisterViewModel can be stored in either of the following paths:Resources/ViewModels.Account.RegisterViewModel.fr.resx Resources/ViewModels/Account/RegisterViewModel.fr.resx
For built-in error messages for identity models (like "This email is already taken.) or basic validation texts you have to do some more configuration. I have documented some work in ASP.Net Core localization.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With