Murat Korkmaz
Murat Korkmaz

Reputation: 1357

.NET Localization - how to set a language?

I've localized my ExportForm into German (de) and Russian (ru) as you can see below:

If my CultureInfo is German (Austrian-de-AT) then all is OK, I see the format translated into German:

string specCult = "de-AT";
Thread.CurrentThread.CurrentUICulture = new CultureInfo(specCult);

But I see the English UI with the Russian (ru-RU) CultureInfo

string specCult = "ru-RU";
Thread.CurrentThread.CurrentUICulture = new CultureInfo(specCult);

Although if I use "ru" instead of the "ru-RU" to create the CultureInfo it works:

string specCult = "ru";
Thread.CurrentThread.CurrentUICulture = new CultureInfo(specCult);

Could you please help me what might invoke be the problem? Or please point me a direction to investigate the problem.

Upvotes: 8

Views: 5059

Answers (2)

Murat Korkmaz
Murat Korkmaz

Reputation: 1357

I've determined the problem: ru-RU was selected as a neutral language in my main project assembly settings.

MSDN: The NeutralResourcesLanguage attribute informs the ResourceManager of the language that was used to display the resources of the neutral culture for an assembly. When it looks up resources in the same culture as the neutral resources language, the ResourceManager automatically uses the resources that are located in the main assembly. It does this instead of searching for a satellite assembly that has the current user interface culture for the current thread. This improves lookup performance for the first resource that you load and can reduce your working set.

http://msdn.microsoft.com/en-us/library/bb385967.aspx

Upvotes: 2

Amit
Amit

Reputation: 22086

ru is the neutral name for the Russian culture, and ru-Ru is the name of the specific Russian (Russia) culture.

This is taken from MSDN link

At startup, the example sets the current culture and the current UI culture to Russian (Russia) on all systems except those on which the default system culture is already Russian (Russia). If the default system culture is already Russian (Russia), the code sets the current culture and the current UI culture to English (United States).

Here is other good explanation

If the resources for a specific culture are not available in the operating system, the resources for the associated neutral culture are used. If the resources for the neutral culture are not available, the resources embedded in the main assembly are used.

The list of locales in the Windows API is slightly different from the list of cultures supported by the .NET Framework. If interoperability with Windows is required, for example, through the p/invoke mechanism, the application should use a specific culture that is defined for the operating system. Use of the specific culture ensures consistency with the equivalent Windows locale, which is identified with a locale identifier that is the same as LCID.

Upvotes: 0

Related Questions