Localizable
-
I've built my Windows Form application with form's localizable property set to true, then configure support for different languages by setting Language property to fr, fr-CA, fr-fr, de, en, en-US, en-UK. I checked, the satellite assemblies were all there in the right subfolders after I compiled the application. I execute the application on my machine, and since it's a "en-us" machine, I get the corresponding UI elements displayed with the corresponding english labels. But, how can I change the CurrentUICulture of my "machine" - so I can see what the GUI looks like under different machine culture setting? I tried Control Panel>Regional and Language Options. I changed settings on "Regional Options" tab, but nothing I did seems to affect how my application chooses its satellite assembly: It always chooses "en-US" despite of the changes??? Thanks in advance.
-
I've built my Windows Form application with form's localizable property set to true, then configure support for different languages by setting Language property to fr, fr-CA, fr-fr, de, en, en-US, en-UK. I checked, the satellite assemblies were all there in the right subfolders after I compiled the application. I execute the application on my machine, and since it's a "en-us" machine, I get the corresponding UI elements displayed with the corresponding english labels. But, how can I change the CurrentUICulture of my "machine" - so I can see what the GUI looks like under different machine culture setting? I tried Control Panel>Regional and Language Options. I changed settings on "Regional Options" tab, but nothing I did seems to affect how my application chooses its satellite assembly: It always chooses "en-US" despite of the changes??? Thanks in advance.
Changing the regional settings - unless you have the appropriate MUI packs for the version of Windows you're running (only on 2000 and XP currently, I believe) - doesn't change your language. Instead, you need to provide a way to change it in your application. If you make a user preference to do this, you have to reset the controls based on the localization information in the satellite assembly. You don't have to re-instantiate the controls or add the controls to their would-be parent's
Controls
collection, but you do have to do practically everything else. An easier way would be to add a key/value pair (say, "language", then the 5-digit lang-culture pair as the value) to your<appSettings>
. In your application - either as the first lines in the main forms's constructor, or before you callApplication.Run
- read the setting withConfigurationSettings.AppSettings["language"]
. If a setting exists, setThread.CurrentUICulture = new Culture(myLangSetting)
. Any other threads that are spawned from the main thread (which the UI must add, remove, and usually update controls on) should inherit the setting from the thread that spawned them.-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----
-
Changing the regional settings - unless you have the appropriate MUI packs for the version of Windows you're running (only on 2000 and XP currently, I believe) - doesn't change your language. Instead, you need to provide a way to change it in your application. If you make a user preference to do this, you have to reset the controls based on the localization information in the satellite assembly. You don't have to re-instantiate the controls or add the controls to their would-be parent's
Controls
collection, but you do have to do practically everything else. An easier way would be to add a key/value pair (say, "language", then the 5-digit lang-culture pair as the value) to your<appSettings>
. In your application - either as the first lines in the main forms's constructor, or before you callApplication.Run
- read the setting withConfigurationSettings.AppSettings["language"]
. If a setting exists, setThread.CurrentUICulture = new Culture(myLangSetting)
. Any other threads that are spawned from the main thread (which the UI must add, remove, and usually update controls on) should inherit the setting from the thread that spawned them.-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----
-
Thanks, I can see what you're getting at. I'll just put a Dropdown box and let user to select CurrentUICulture.
Actually, I think you missed my point. If you use a drop-down, this implies that you're UI is already running (unless you use a modal dialog before calling
Application.Run
, which can be tricky depending on a number of factors). If you do this, to change the UI culture you have to completely reset EVERY SINGLE CONTROL in your application. This is especially tedious when you have multiple forms. Switching languages while a program is running - especially larger programs - is definitely not a trivial thing. If users require different languages on their Windows machine, then they might just have the appropriate MUI pack installed and enabled. They will see the appropriate localized UI automatically. If you just require this for testing, use the config file. If nothing else, companies that require a different localized UI can change the config file when - for native applications - they would change the registry (using the registry for .NET apps is not recommended). It's not like users are going to be changing the UI culture often, right? :) Why make it much more difficult on yourself. That's what I was getting at - keep it simple. Assign the UI Culture before you start your application (which means the main UI thread, which will effect all threads spawned from it). You'll save yourself A LOT of trouble.-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----
-
Actually, I think you missed my point. If you use a drop-down, this implies that you're UI is already running (unless you use a modal dialog before calling
Application.Run
, which can be tricky depending on a number of factors). If you do this, to change the UI culture you have to completely reset EVERY SINGLE CONTROL in your application. This is especially tedious when you have multiple forms. Switching languages while a program is running - especially larger programs - is definitely not a trivial thing. If users require different languages on their Windows machine, then they might just have the appropriate MUI pack installed and enabled. They will see the appropriate localized UI automatically. If you just require this for testing, use the config file. If nothing else, companies that require a different localized UI can change the config file when - for native applications - they would change the registry (using the registry for .NET apps is not recommended). It's not like users are going to be changing the UI culture often, right? :) Why make it much more difficult on yourself. That's what I was getting at - keep it simple. Assign the UI Culture before you start your application (which means the main UI thread, which will effect all threads spawned from it). You'll save yourself A LOT of trouble.-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----