AyKarsi
AyKarsi

Reputation: 9685

Display standard razor/mvc 3 validation messages displayed in another language

What do I need to install to get the built-in validation messages of mvc be displayed in the current UI culture of the request? Are the resource files maybe a separate download?

e.g. The validation message "The Email field is required." Should be displayed in german when the culture is set to de-DE.

EDIT: Need to be a bit clearer. I've done the complete localisation of custom validation messages allready using attributes with custom messages. The ones I still need to get translated are the out-of-the box ones.

e.g.

[Required]
public string Email {get;set;}

produces the validation message The Email field is required. I'd like to have this in german and italian also, without having to go through every single property. (I am expecting there is language pack or something similar; Google wasn't able to produce anything though..)

Upvotes: 1

Views: 2729

Answers (4)

Mutz
Mutz

Reputation: 21

Try to add the following in your Web.config file.

<system.web>
<globalization enableClientBasedCulture="true" uiCulture="auto" culture="auto"></globalization>
</system.web>

I think that is what you are looking for.

Upvotes: 2

jgauffin
jgauffin

Reputation: 101166

I've come up with a better way to localize models and validation messages. You do not have to use the attributes anymore. Instead I've created localized metadata providers.

http://blog.gauffin.org/2011/09/easy-model-and-validation-localization-in-asp-net-mvc3/

Upvotes: 1

Michael Sander
Michael Sander

Reputation: 2722

Just install the the dot net 4 full language pack in the desired language and you will get the localization of the DataAnnotations validation messages.

Upvotes: 0

Darin Dimitrov
Darin Dimitrov

Reputation: 1039160

I would recommend you checking out the following guide.

Upvotes: 0

Related Questions