How to respect / inherit user language settings in WinForm application?

I've worked with globalization settings in the past, but not in the .NET environment, which is the topic of this question. What I see is of course related to knowledge that I have not yet explored, so I would rate the lighting as follows.


Setting: My default language is English (en-us specifically). I added a second language (Danish) to my development system (WinXP) and then opened the language bar so I could choose at will.


I selected Danish in the language bar and then opened Notepad and found that the language switched to English in the language bar. I understand that there is a language setting for each application, so it seemed like Notepad set the default to English. (I found this strange because Windows, and therefore Notepad, is used all over the world.) Closing Notepad reverted the setting in the language bar to Danish. Then I ran the open custom WinForm app, which I know doesn't set the language - and it also reverted from English to Danish when it was opened, then reverted back to Danish when it ended!

Question # 1A: How do I force a WinForm application to inherit the current language bar settings on startup? My experiment seems to indicate that every application starts with a system default and requires the user to manually change it after starting the application - this seems to be a major inconvenience for those looking to work with multiple languages!

Question # 1B: If I need to essentially manually set the language in a multilingual script, how do I change the default system language (for example, to Danish) so that I can test my application launch in a different language?


I added the display of the current language in my application for the next experiment. Specifically, I installed a handler MouseEnter

on the shortcut that sets its tooltip CultureInfo.CurrentCulture.Name

, so every time I click I thought I should see the current language setting. Since setting the language before launching the application did not work, I ran it and then set the language to Danish. I've found that some things (like typing text into a TextBox) honor this Danish setting. But the mouse over the instrumental label still showed en-us!

Question # 2A: Why CultureInfo.CurrentCulture.Name

doesn't it reflect the change in my language bar while other parts of my application seem to recognize the change? (An attempt CultureInfo.CurrentUICulture.Name

gave the same result.)

Question # 2B: Is there an event that fires when the language bar changes so that I can recognize in my application when the language setting changes?


2010.05.13 Update

The brief but weak information provided by Eric of Microsoft (see his answer below) directly addressed only one of my four questions (# 2A), but it just provided the impetus that I needed to dig deeper and find out the rest. For the benefit of others who may also be drugged by this, here's what I found:

Answer # 1A: The application inherits the default input language setting, not the language you specify in the language bar. After the application is launched, changes in the language bar will be immediately noticed by your application.

Answer # 1B: Setting the default input language is done using the Regional and Language Settings Control Panel → Languages ​​tab → Details → Settings tab → Default Input Language.

Answer # 2A: Answered by Eric, the current culture is different from the current input language, which is reflected in the language bar; entering text into a text box depends only on the current input language.

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

+2


a source to share


1 answer


There are three separate languages ​​in the game. The language bar controls the InputLanguage , which is different from the UI display language (CurrentUICulture), which is different from the sorting / formatting / parsing language (CurrentCulture).



It is true that this is confusing.

+1


a source







All Articles