Localization of MVC3 Validation Messages

I am trying to localize data annotation validation messages. I thought this could be done as described here: Support for ASP.NET MVC 3 Validation with non-English languages .

Now he says that ASP.NET MVC and types in the System.ComponentModel.DataAnnotations namespace use their own localized messages. So is it more or less useless for me and just help for formatting, for example, prices?

But back to the real question, so the only way to localize verification messages is something like this? localize default model check in mvc 2

Just trying to get some clean up here, thanks =)

+6
source share
3 answers

Resources for data annotations are provided in the .NET Framework 4. You need to install the language pack for the .NET Framework.

+3
source

You can use resource files:

public class UserViewModel { [Required(ErrorMessageResourceName = "Required", ErrorMessageResourceType = typeof(UserResources))] [Display(Name = "FirstName", ResourceType = typeof(UserResources))] public string FirstName { get; set; } } 

You can check out the next blog post .

+3
source

Just install the full dot net 4 language pack in your preferred language and you will receive the localization of DataAnnotations data validation messages.

0
source

Source: https://habr.com/ru/post/888180/


All Articles