1

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

4 Answers 4

2

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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/

Comments

0

I would recommend you checking out the following guide.

4 Comments

I know that article.. Clarified the question. See Edit.
@AyKarsi, you will have to go through those Required attributes and set the ErrorMessageResourceName and ErrorMessageResourceType properties if you want to localize the validation error messages.
hmm. I was hoping for more, but I does the trick nonetheless. Thanks!
This is actually the most common way to do it.
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.