Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Do you really need all the language resources stored in a single binary? By default, .NET looks for resources for the non-default language in separate 'satellite' .dlls, in a subdirectory next to your main .dll named after the language.</p> <p>For example, if your .dll is called MyProject.dll, you'd have a jp-JP\MyProject.dll, fr-BE\MyProject.dll, etc. Note that these extra .dll's only contain the resources; your code is compiled into the main .dll. You'd need to deploy these salellite .dll's together with your main .dll.</p> <p>To automatically create such satellite .dll's in Visual Studio, you'd create an Xyz.resx for your default translations, and Xyz.<em>lang</em>.resx for every language you want to translate into, e.g., Xyz.jp-JP.resx or Xyz.de-AT.resx. Visual Studio will take care of creating a <em>lang</em>\MyProject.dll satellite assembly for each language used, which will contain the resources of all *.<em>lang</em>.resx files in your project together.</p> <p>In this setup, you can access the right resources through a <code>ResourceManager</code>, just like the default resources, by passing the proper <code>CultureInfo</code> as the second parameter to <code>GetString</code> or <code>GetObject</code>. The easiest way is to use the generated resource class, which already has a properly configured <code>ResourceManager</code> available:</p> <pre><code>CultureInfo culture = new CultureInfo("jp-JP"); ... string labelText = ResourceName.ResourceManager.GetString("SomeKey", culture); </code></pre> <p>Note that if you'd like to make this process a little easier, you could set the <code>Thread</code>'s <code>CurrentUICulture</code> to the right culture, and then all resource lookups without a culture specified will use the <code>CurrentUICulture</code> (on that particular thread only):</p> <pre><code>Thread.CurrentUICulture = new CultureInfo("jp-JP"); ... string labelText = ResourceName.SomeKey; </code></pre> <p>This is a lot easier and most other parts of the .NET Framework will start using the same language as part of their messages and other localization settings. If they are available, that is. (You might need to install a language pack.) If they are not available, the Framework will fall back to another language (usually English).</p> <p>However, if you only want <strong>your</strong> resources to be translated, you'd need to go the way of the <code>ResourceManager.GetString</code> calls.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload