Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET MVC validation message does not get localized

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?

like image 897
Gerwald Avatar asked Aug 14 '13 10:08

Gerwald


2 Answers

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".

like image 157
Fabio S Avatar answered Nov 08 '22 19:11

Fabio S


Yes - reference your resource file in your validation attributes:

[Required(ErrorMesageResourceName="LastName", ErrorMessageResourceType=typeof(YourResourceClassName))]
like image 3
Joe Ratzer Avatar answered Nov 08 '22 19:11

Joe Ratzer