I have read most of the literature Google and SO provides on this (correct me if I've missed something).
What I am trying to do is to localize an MVC site using resources, I want the compiletime safety of strongly typed resource files (ResX) but the flexibility of the ASP.NET 2.0 Resource-Provider Model, or something similar to that. I dont mind doing some work but it seems all paths I've researched lead to a dead end.
For displaying localized text in views I can hack together a helper to pull resources from HttpContext.Get(Global|Local)ResourceObject but that gets me nowhere when it comes to model validation and scaffolding, I suppose I could subclass the attributes and provide data but since it means pulling stuff from HttpContext I doubt that is available at the time the attributes are activated.
Since the direction localization in MVC seems to be toward ResX files and away from the 2.0 Resource-Provider model I could try to inject myself in the classes generated by the ResXFileCodeGenerator with a custom ResXFileCodeGenerator to provide my own ResourceProvider but that is terribly hackish involving custom Visual Studio Addins and codegeneration.
So my question is basically, what's the story with flexible MVC localization?
The referenced literature below:
- http://adamyan.blogspot.com/2010/02/aspnet-mvc-2-localization-complete.html
- http://msdn.microsoft.com/en-us/library/aa905797.aspx
- http://www.eworldui.net/blog/post/2008/10/ASPNET-MVC-Simplified-Localization-via-ViewEngines.aspx
- http://ryanrivest.com/blog/archive/2010/01/15/reusable-validation-error-message-resource-strings-for-dataannotations.aspx
- http://www.codeproject.com/KB/dotnet/ResXFileCodeGeneratorEx.aspx