i have an asp.net mvc application, and i use data annotations for data validations something like this:
public class Booking
{
[Required(ErrorMessage = "Please enter your name")]
public string Name { get; set; }
...
so this is in my DomainModel and i need to translate the ErrorMessage, and to use the translation in my views
i would like to have just one resource file for each language
anybody knows so开发者_如何学编程me solutionus ?
Put your error messages in resource files, and apply ErrorMessageResourceName
and ErrorMessageResourceType
instead of ErrorMessage
on the Required
attribute. See here: http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.requiredattribute_members.aspx
精彩评论