Reputation: 1
I work in a company and our app is localizable, but we have encountered a problem.
Original language is PL and we have EN translation in satellite assemblies (*.resource files translated using Sisulizer).
When we run our app without changing language on english OS, our app is translated to EN in some places and I can't find why.
When we have 'original' PL language it should stay PL and not look for any satellite assemblies to translate itself for OS language. We have CurrentUICulture set to pl-PL but when I run Assembly Binding Log Viewer it shows that one of dll's is looking for *.resources file with culture=en.
More to say, this dll is Base class dll. BaseForms is subproject holding all base forms and it's built as dll. This dll is looking for *.resources in log. ourAppName is another subproject that is built as exe and it has some forms that derives from BaseForms, f.e. Main Form.
any tips, please?
Upvotes: 0
Views: 415
Reputation: 1047
It seems that some other part of you application (might even be a library that you uses) sets the CurrentUICulture to Enhlish on runtime. I have see this happening few times. Every single time some library code has changed the CurrentUICulture. Try to locate the moment when this happens either by debugging or figuring out from the the strings that appear in English.
Upvotes: 0
Reputation: 2407
There are several places where to set the culture. For a WPF application, you can use:
[DllImport("Kernel32.dll", CharSet = CharSet.Auto)]
private static extern ushort SetThreadUILanguage(ushort _languageId);
public static void SetLanguage(string uiLanguage)
{
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(uiLanguage);
CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.GetCultureInfo(uiLanguage);
SetThreadUILanguage((ushort) Thread.CurrentThread.CurrentUICulture.LCID);
FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentUICulture.IetfLanguageTag)));
}
Note that the last line is for WPF only, and DefaultThreadCurrentUICulture
requires C#5 (if you use an earlier version of the framework, you have to set the culture for every thread individually).
Upvotes: 0