Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Localizable

Localizable

Scheduled Pinned Locked Moved C#
questiondesign
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    CillyMe
    wrote on last edited by
    #1

    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.

    H 1 Reply Last reply
    0
    • C CillyMe

      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.

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      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 call Application.Run - read the setting with ConfigurationSettings.AppSettings["language"]. If a setting exists, set Thread.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-----

      C 1 Reply Last reply
      0
      • H Heath Stewart

        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 call Application.Run - read the setting with ConfigurationSettings.AppSettings["language"]. If a setting exists, set Thread.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-----

        C Offline
        C Offline
        CillyMe
        wrote on last edited by
        #3

        Thanks, I can see what you're getting at. I'll just put a Dropdown box and let user to select CurrentUICulture.

        H 1 Reply Last reply
        0
        • C CillyMe

          Thanks, I can see what you're getting at. I'll just put a Dropdown box and let user to select CurrentUICulture.

          H Offline
          H Offline
          Heath Stewart
          wrote on last edited by
          #4

          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-----

          C 1 Reply Last reply
          0
          • H Heath Stewart

            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-----

            C Offline
            C Offline
            CillyMe
            wrote on last edited by
            #5

            You're right, configure it before loading the application or UI is constructed. Point well taken.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups