I need a solution for ASP.NET MVC3 model validation logic. I have a custom localization solution and i'm passing all strings through a method for translating, something like that:
@Localizer.Translate("Hello world!")
Note: I'm not sure but i think this approach comes from QT localizastion logic. WordPress is using smillar technique also.
When i try to apply this solution for model validation attributes like that:
[Required(ErrorMessage = Localizer.Translate( "Please enter detail text!"))]
[DisplayName(Localizer.Translate( "Detail"))]
public string Details { get; set; }
compiler gives me this error:
Error 1 An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type...
So, i tried to modify error messages and DisplayName attributes on the fly, but i couldn't.
Is there a any way to do this? If there is, it could be life saver for me :)