views:

300

answers:

1

Hi,

I have a web application built in asp.net, which uses resource files to support multiple languages. The problem I have is that I can only add a new language file in Visual Studio, and I have to rebuild the whole application to have a the new language included. After searching the net I've found out that the compilation of the resource files can be done in the .net compiler. I've used the following commands:

resgen.exe /compile langfile.en.resx

al.exe /out:en\App_GlobalResources.resources.dll /culture:en /embedresource:langfile .en.resources

The file is copied into the website's folder but it doesn't work. I mean, when I select the new language from the web page, the strings are loaded from the default resource file. If I create the resource file in VS, it works okay. I checked the sizes of the two dll files, the one generated by VS and the one compiled by myself, and they have the same size but the compiled one doesn't work. I can only think that maybe I would have to use some other parameters in the commands above but I don't really know.

Any help is really appreciated.

+2  A: 

You can achieve what you want by writing your own expression builder instead of using the built-in resources version and pull the information from a database or XML files. Basically you write your own class inheriting from System.Web.Compilation.ExpressionBuilder and then register it in Web.config like this:

<compilation>
  <expressionBuilders>
    <add expressionPrefix="CustomResources" type="CustomResourcesExpressionBuilder"/>
  </expressionBuilders>
</compilation>

and then you can reference it like normal resources:

<%$ CustomResources:Section, Key %>

You can find some articles on this here and here.

Rob West