0
votes

I've got a problem with localization - it retrieves incorrect value sometimes. Here is my case:

In every assembly I have NeutralResourcesLanguage set to en-US.
List of available resources is: default (english) fr, de.

So I have English OS and I chose any language - everything is fine (UICulture is set to en, fr or de and Culture is en-US, de-DE or fr-FR respectively).

But when I have German OS and chose English language (UICulture is en and Culture is en-US) -some strings are in German.

Also if I leave Thread.CurrentThread.CurrentUICulture == "de" and Thread.CurrentThread.CurrentCulture = "en-US" then some text will be in english..

Any explanation and solution to this?

2

2 Answers

0
votes

You need to use proper language codes, in your case these would be en, fr and de.

Do not use specialised language code when this is not necessary, so use just fr if you have only one French translation.

You should use more specialised ones only only when necessary.

Update: on Windows you cannot fully control the language of the messages you are getting from the OS. Usually they will use your current thread locale but sometimes they will use the OS default language and you can do nothing about it. Just document the behaviour for the users.

0
votes

I found the problem - I was using DependencyProperty with default value like PropertyMetadata(Resources.Text). And since DP is static it was initializing with system language BEFORE actual localization setting were applied in ApplicationStartup handler.