Do you really need all the language resources stored in one binary file? By default, .NET searches for resources for a non-default language in separate "satellite" DLL files in a subdirectory next to your main .dll, named after the language.
For example, if your .dll is called MyProject.dll, you will have jp-JP \ MyProject.dll, fr-BE \ MyProject.dll, etc. Please note that these additional .dlls contain only resources; your code is compiled into the main .dll. You will need to deploy these salellite.dll along with your main .dll.
To automatically create such a satellite .dll in Visual Studio, you must create Xyz.resx for your default translations and Xyz.lang.resx for each language you want to translate, for example, Xyz.jp-JP. resx or Xyz.de-AT.resx. Visual Studio will take care of creating the lang \ MyProject.dll compilation for each language used, which will contain the resources of all * .lang.resx files in your project together.
In this setting, you can access the correct resources through the ResourceManager
, like the default resources, by passing the correct CultureInfo
as the second parameter to GetString
or GetObject
. The easiest way is to use the generated resource class that already has a properly configured ResourceManager
available:
CultureInfo culture = new CultureInfo("jp-JP"); ... string labelText = ResourceName.ResourceManager.GetString("SomeKey", culture);
Note: if you want to make this process a little easier, you can set Thread
CurrentUICulture
to the correct culture, and then all resource searches without the specified culture will use CurrentUICulture
(on this particular thread):
Thread.CurrentUICulture = new CultureInfo("jp-JP"); ... string labelText = ResourceName.SomeKey;
This is much simpler, and most other components of the .NET Framework will begin to use the same language as part of their messages and other localization parameters. If they are available, that is. (You may need to install the language pack.) If they are not available, the Framework will return to another language (usually English).
However, if you want resources have been translated, you will need to follow the path of calls to ResourceManager.GetString
.