How can I localize localize error messages without specifying them on DataAnnotations
for models? Eg 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.
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.
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.