views:

88

answers:

1

I have worked with globalization settings in the past but not within the .NET environment, which is the topic of this question. What I am seeing is most certainly due to knowledge I have yet to learn so I would appreciate illumination on the following.


Setup: My default language setting is English (en-us specifically). I added a second language (Danish) on my development system (WinXP) and then opened the language bar so I could select either at will.


I selected Danish on the language bar then opened Notepad and found the language reverted to English on the language bar. I understand that the language setting is per application, so it seemed that Notepad set the default back to English. (I found that strange since Windows and thus Notepad is used all over the world.) Closing Notepad returned the setting on the language bar to Danish. I then launched my open custom WinForm application--which I know does not set the language--and it also reverted from English to Danish when opened, then back to Danish when terminated!

Question #1A: How do I get my WinForm application upon launch to inherit the current setting of the language bar? My experiment seems to indicate that each application starts with the system default and requires the user to manually change it once the app is running--this would seem to be a major inconvenience for anyone that wants to work with more than one language!

Question #1B: If one must, in fact, set the language manually in a multi-language scenario, how do I change my default system language (e.g. to Danish) so I can test my app's launch in another language?


I added a display of the current language in my application for this next experiment. Specifically I set a MouseEnter handler on a label that set its tooltip to CultureInfo.CurrentCulture.Name so each time I mouse over I thought I should see the current language setting. Since setting the language before I launch my app did not work, I launched it then set the language to Danish. I found that some things (like typing in a TextBox) did honor this Danish setting. But mousing over the instrumented label still showed en-us!

Question #2A: Why does CultureInfo.CurrentCulture.Name not reflect the change from my language bar while other parts of my app seem to recognize the change? (Trying CultureInfo.CurrentUICulture.Name produced the same result.)

Question #2B: Is there an event that fires upon changes on the language bar so I could recognize within my app when the language setting changes?


2010.05.13 Update

The short but sweet information provided by Eric from Microsoft (see his answer below) directly addressed only one of my four questions (#2A) but it provided just the impetus I needed to delve further and figure out the rest. For the benefit of others who may also be befuddled by this, here is what I uncovered:

Answer #1A: An application inherits the setting of the default input language, not the language you specify on the language bar. Once your application is running, then changes on the language bar will be noticed immediately by your app.

Answer #1B: Setting the default input language is done via Regional and Language Options control panel >> Languages tab >> Details >> Settings tab >> default input language.

Answer #2A: Answered by Eric, the current culture is distinct from the current input language that is reflected on the language bar; typing in a text box is influenced only by the current input language.

Answer #2B: There is no predefined event for either input language or current culture change notification. An important fact to note here is that input language changes are automatically recognized immediately while current culture changes are not. You must restart your application for a current culture change to take effect--unless you can notice the change and act upon it yourself. To that end I found an MSDN article (The Many Faces of the CultureInfo Class) that provides just such a hook to notice the change.

A: 

There are three separate language settings at play. The language bar controls the input language (InputLanguage) which is distinct from the language for displaying UI (CurrentUICulture) which is distinct from the language for sorting/formatting/parsing (CurrentCulture).

It is true that this is confusing.

Eric MSFT
"Aha!" I proclaimed upon reading your answer. Though technically you only directly answered question #2A (one out of four) I am recognizing your solution as the official answer since it enabled me to derive the remaining answers I needed for my application--see my revised comments in the question above.
msorens