I’m trying to do localization in MVC3, and I want to use a database to store the resources. I’ve read up on resource providers, but I haven’t found a way of using a resource provider without losing the strongly-typed access that a regular resource file has.
So, what is the best way to do localization, while maintaining strongly-typed access? (Ideally with a database too)
If you want to store the entries in a database you can do the same trick as the normal resource files in Visual Studio are doing for you.
Normally the resource file is parsed and a static class is generated from it. In your case you could us a T4 template(Code Generation and T4) to connect to the database and build a resource class from the ‘Id’ columns in your database you have the same resource class.
On startup you could load the translated strings from the database and initialize your T4 resource class with it.