Localization Notes

From UW Center for Collaborative Technologies Wiki
Jump to: navigation, search


The ResourceManager will attempt to look up strings at runtime for the language indicated by the thread's CurrentUICulture property. If the string is not found, the Resource manager will fall back to the default string which in our case will be the English language string. The default string resources are by definition those that are built-in to each assembly. The additional language resources are compiled as Satellite assemblies. These are assemblies that contain only the resource and no code.

How to build Satellite Assemblies

The simple way to build Satellite assemblies is to add all of the Strings.xx-YY.resx to the appropriate projects. Having done this, Visual Studio will automatically build the satellite assemblies when building the project.

The Satellite assemblies will be named 'Projname.resources.dll' (for a project named 'Projname'). In order to be located at runtime by the resource manager, the satellite assemblies must be in directories beneath the application directory, for instance, the satellite assemblies for French language for a project built with Debug configuration will end up in: Projname\bin\Debug\fr\

Under the covers, Visual Studio is using two .Net tools to compile the .resx files into the satellite assemblies: resgen.exe and al.exe. If we need to script the build process we would use commands such as the following:

resgen.exe Strings.fr.resx
al.exe /t:lib /embed:Strings.fr.resources,Projname.Strings.fr.resources /culture:fr /out:Projname.resources.dll

Overriding the Default Language

The language that the resource manager will try to display to the user depends on the value of CurrentUICulture which has been set on the current thread. The default value of this property when a thread is created depends on Windows language setting. If we want the application to use a different language than the Windows language, we need to manually set the CurrentUICulture property. Note: As far as I can tell we need to manually set this property on each and every thread that uses localized resources.

Demonstration App

This application demonstrates a localized application with a localized library, an additional thread, and a language override method using app.config: Demo App.