- changed milestone to Alpha
- changed title to Ensure default validation messages are localized
- changed component to Project-General
Ensure default validation messages are localized
When model classes passed in are using validation attributes:
public class MyViewModel
{
[Required]
public string Name { get; set; }
// Etc., for other properties
}
and are then validated using our helper class:
public void AddStuff(MyViewModel model)
{
CentrisValidation.Validate(model);
// Throws an error if validation fails...
}
By default, this will result in English validation messages. We should however use the Accept-Language header in requests (example code can be seen here: http://damienbod.wordpress.com/2014/03/20/web-api-localization/ how to extract that value from the HTTP request, but the license for that code must be specified first), and then somehow switch the actual error messages depending on the language passed in.
The following article: http://www.codeproject.com/Articles/254064/Easy-model-and-validation-localization-in-ASP-NET explains how this can be done, however the sample code doesn't compile (yet). I've created an issue at the github page of the project (https://github.com/jgauffin/griffin.mvccontrib), and hopefully that will be sorted out soon.
Comments (2)
-
Account Deactivated reporter -
Account Deactivated reporter - changed milestone to Beta
- Log in to comment