0

enter image description here

The autogenerated text from the validation @html.validationmessagefor auto generates a text in english, i want this text to be in spanish, but whithout touch the data anotation of the property in the view model.

Internationalization its not an option! Data anotations nether!

tereško
  • 58,060
  • 25
  • 98
  • 150
Milo
  • 312
  • 1
  • 6
  • 15

2 Answers2

0

I have used Resource files (.RESX) to extract the localized error message

public class BasicInfoViewModel 
{
 [Required(ErrorMessageResourceName = "REQ_FN", 
           ErrorMessageResourceType = typeof(Resources.Messages))]
 [StringLength(100)]
 public string FirstName { get; set; }
}

Then In

Resources/Messages.resx file

REQ_FN -> First Name Required

Resources/Messages.(cultureCode).resx file

REQ_FN -> Custure specific message for (First Name required)

Murali Murugesan
  • 22,423
  • 17
  • 73
  • 120
  • This is not a localization problem the problem is the lenguaje of the library generating the message... – Milo Oct 16 '13 at 15:11
0

I got the solution!

In the console http://docs.nuget.org/docs/reference/package-manager-console-powershell-reference

First uninstall MVC 4 reference packages:

PM> Uninstall-Package Microsoft.AspNet.Mvc

Then install MVC 4 package in spanish:

PM> Install-Package Microsoft.AspNet.Mvc.es -Version 4.0.30506

enter image description here regards!

Milo
  • 312
  • 1
  • 6
  • 15