解决方法
如果你碰巧使用ASP.NET MVC 4以上,请检查此帖子:
Localizing Default Error Messages in ASP.NET MVC and WebForms
基本上你必须在Global.asax的Application_Start()方法中添加以下代码:
ClientDataTypeModelValidatorProvider.ResourceClassKey = "Messages"; DefaultModelBinder.ResourceClassKey = "Messages";
在Visual Studio中的解决方案资源管理器中右键单击您的ASP.NET MVC项目,然后选择Add =>添加ASP.NET文件夹=> App_Global资源。
现在在此文件夹中添加一个名为Messages.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.
你应该很好去。
注意,你感兴趣的值是FieldMustBeNumeric。要将其本地化为西班牙语,您必须添加另一个名为Messages.es.resx的资源文件。在此特定.resx文件中,将资源值替换为:
Name Value ==== ===== FieldMustBeNumeric El campo {0} tiene que ser numerico.
如果你碰巧使用ASP.NET MVC 3向下,这个解决方案可以帮助你实现相同的结果:http://stackoverflow.com/a/2551481/114029
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。