1

How can I localize localize error messages without specifying them on DataAnnotations for models? E.g. in message "The field XX is required", I want to translate only "The field --is required" part with jQuery globalization, I'm not using [Required(ErrorMessageResourceName="----")] attributes.

Is it possible to achieve this? Any code samples, tutorial links will be appreciated.

Lev
  • 3,719
  • 6
  • 41
  • 56

2 Answers2

1

You can try the following approach:

[Display(Name = "FirstName", ResourceType = typeof(Resources.Resources))] 
[Required(ErrorMessageResourceType = typeof(Resources.Resources), ErrorMessageResourceName = "ErrorRequired")]
public string FirstName {get;set;}

Then in your Resource file you add key:

FirstName and translate e.g. with "first name"
ErrorRequired --> "{0} field is required"

This approach you can then apply to all your properties.

Eleasar
  • 529
  • 9
  • 20
1

You can find the answer for jquery based resource location which I have developed. Very useful plugin. Please see the answer posted here https://stackoverflow.com/a/30610862/1239344

Community
  • 1
  • 1