title: Providing localized error messages for non-attributed model validation in ASP.Net MVC 2?
body: <p>I'm using the <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.aspx" rel="noreferrer">DataAnnotations</a> attributes along with ASP.Net MVC 2 to provide model validation for my ViewModels:</p>
  
  <pre><code>public class ExamplePersonViewModel {
      [Required(ErrorMessageResourceName = "Required", ErrorMessageResourceType = typeof(Resources.Validation))]
      [StringLength(128, ErrorMessageResourceName = "StringLength", ErrorMessageResourceType = typeof(Resources.Validation))]
      [DataType(DataType.Text)]
      public string Name { get; set; }
  
      [Required(ErrorMessageResourceName = "Required", ErrorMessageResourceType = typeof(Resources.Validation))]
      [DataType(DataType.Text)]
      public int Age { get; set; }
  }
  </code></pre>
  
  <p>This seems to work as expected (although it's very verbose). The problem I have is that there are behind-the-scenes model validations being performed that are not tied to any specific attribute. An example of this in the above model is that the <code>Age</code> property needs to be an <code>int</code>. If you try to enter a non-integer value on the form, it will error with the following (non-localized) message:</p>
  
  <blockquote>
    <p>The field Age must be a number.</p>
  </blockquote>
  
  <p><strong>How can these non-attribute validation messages be localized?</strong></p>
  
  <p><strong>Is there a full list of these messages available so I can make sure they are all localized?</strong></p>