views:

62

answers:

1

Hello.

I have just started writing a multilingual application for the very first time. I have read about the concept of language resource files and I think I get the main idea. I have tried to implement it, and instantly found an issue:

I have entered the default language strings to a resx file, and then added another resource file (for example: UIStrings.en.resx). Since my company is not based in England / other English speaking countries, our applications are primarily written in our language. Thus default language is our language (Slovenian).

When I add the .en.resx file and insert the correct translations and run the program it now displays English text. I figured that is because

CultureInfo.CurrentUICulture = "en-US" 

while

CultureInfo.Currentculture = "sl-SI"

I figure this is because I am running English version of windows (though all the properties in Regional Options are set correctly to Slovenian settings).

How can I make the application display the strings in the users language, not the installed windows language?

+1  A: 

I have found out this blog post that answers my question.

If anyone else is struggling with this, here is what you do:

So, if you are using the most common version of Windows (Englis version), you are stuck with the “en-US” culture; hence, your application will always use your English resource. In order to mitigate this, you can perform a little trick at your application startup. You can mislead your application to look in your CurrentCulture property instead of CurrentUICulture property. At the application startup, you can write something like this:

Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;

This way, your application will use your globalization setting instead of your default windows localization setting. Your application will be localized to your globalization language and culture. If you change the Regional Settings in your Control Panel, your application language and culture will change automatically.

Rekreativc
That's exactly what I told you and what I've earned is a -1 :)
Thomas Wanner
@Thomas: No, you told me to hard code it to a language (culture info) of my preference. I do not want it fixed, nor do I want to manually store it anywhere. I wanted the application to use culture set in the Windows Regional Options.
Rekreativc
Sorry, but your question was *How can I make the application display the strings in the users language, not the installed windows language?*, so I thought you don't want to use any windows options. But whatever works for you man, I don't care..
Thomas Wanner
@Thomas: Don't get me wrong I still appreciate your answer, I just don't think it helped me.
Rekreativc