ASP.NET MVC validation message does not get locali

2019-02-06 09:08发布

I am using ASP.NET MVC 4 with unobtrusive clientside validation. The language in my application is german (defined in the web.config file)

If i have a required field (configured with data-annotations in my Code First Classes), the client side validation works fine. the only downside: The Message is not Localized.

The Field XXXX is required.

Is there a solution out for this problem?

2条回答
做自己的国王
2楼-- · 2019-02-06 09:44

You must install the .NET Framework Language pack, according to your .NET Framework version:

Microsoft .NET Framework 4.5 Language Pack: http://www.microsoft.com/de-de/download/details.aspx?id=30667

Microsoft .NET Framework 4 Full Language Pack: http://www.microsoft.com/de-de/download/details.aspx?id=23067

In these pages, check the requirements, in order to see if they meets your needs (i.e.: Operating System Version, x86 or x64, etc.). If they don't meet your needs, search on Google something like "Microsoft .NET Framework German Language Pack".

查看更多
小情绪 Triste *
3楼-- · 2019-02-06 09:44

Yes - reference your resource file in your validation attributes:

[Required(ErrorMesageResourceName="LastName", ErrorMessageResourceType=typeof(YourResourceClassName))]
查看更多
登录 后发表回答