views:

325

answers:

2

I would like to store the resource files (containing texts for labels etc.) for my web application in the database to be able to edit and create them dynamically later (probably in the UI). My idea was to store the whole resx file in an xml column and simply load it on demand - depending on the language and some other attributes of the current user when he is logging into the application or switching the context. The important thing is that the resources do not only depend on the culture info of the user but also on some context information that can be switched by user without logging off and on again (in our case called "group", not having anything to do with a group of users).

Is it possible somehow to load the contents of the resources from an external source and simply switch them without web application being recompiled by the server ? I know that there are some interfaces on which I could hook up and implement a custom resources provider which reads from the database directly but if it could work somehow with the resx files it would probably make things a lot easier..

A: 

I would like to know that too.. :-/

A: 

Pretty late but since there is no answer as of yet.

System.Resources.ResourceReader resourceReader 
    = new System.Resources.ResourceReader("PathToResourceFile");

That's pretty much it. Now you can create resource files like en.resx or de.resx and load them depending on the users language. Something like

System.Resources.ResourceReader resourceReader 
    = new System.Resources.ResourceReader(HttpContext.Current.Request.UserLanguages[0] 
    + ".resource");

Keep in mind to provide a default language (resource file) for a user with a language you don't support.

Edit:

Take a look at this link.

Dänu