我可以为您翻译 "The field Date must be a date." 这个验证信息。另外,我已经在 Global.asax 的 Application_Start() 中添加了以下的键。
ClientDataTypeModelValidatorProvider.ResourceClassKey = "ModelBinders";
DefaultModelBinder.ResourceClassKey = "ModelBinders";
我已经在App_GlobalResources中创建了ModelBinders.resx、ModelBinders.nl.resx和ModelBinders.fr.resx。
我已在.resx文件中添加了以下字符串资源(或翻译):
Name Value
==== =====
FieldMustBeDate The field {0} must be a date.
FieldMustBeNumeric The field {0} must be a number.
PropertyValueInvalid The value '{0}' is not valid for {1}.
PropertyValueRequired A value is required.
当我提交一个日期字符串时,我会收到 "FieldMustBeDate" 的翻译。当我提交一个无效的日期(例如 "01/01/201a")时,我会收到默认的 ModelBinders.resx 中定义的未翻译消息 "PropertyValueInvalid",而不是翻译后的消息...我该如何显示 PropertyValueInvalid 的正确翻译?