views:

29

answers:

1

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:

A: 

A resource provider should work fine (i.e. http://msdn.microsoft.com/en-us/library/aa905797.aspx). I've been using this in some projects with a SQL Server backed provider, works fine. It allows you to use all ASP.NET localization features and all the validation attribute translations using resources as well.

maartenba
Sorry for my late reply, the problem I've encountered with using the resources provider model is that it forces me to use resource expressions and the HttpContext.Get(Global|Local)ResourceObject approach to get resources. I want to be able to say <%=Resources.MainView.Title%> for example. If I use the later approach, it wont call into the custom resources provider at all (which is clear by looking into the generated code of the resx file). If I'm going to have to build my own HtmlHelper methods and my own validator attributes then what is the point of the framework at all?
kaa