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. Dynamically updating the CultureInfo

Dynamically updating the CultureInfo

Scheduled Pinned Locked Moved C#
questionwinformsdesigntutorial
4 Posts 3 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.
  • R Offline
    R Offline
    roel_
    wrote on last edited by
    #1

    Hi, I can translate my application using the procedure described in the MSDN article 'Walkthrough: Localizing Windows Forms'. In that article, one one language is set, by instantiating a CultureInfo() in the constructor of the from and setting it on the current thread's CurrentUICulture. But now, how do I dynamically (at run time) change the language that the UI is show in? I've tried calling InitializeComponent() after setting Thread.CurrentThread.CurrentUICulture but that doesn't work. I know I can have the user close the application and restart it so that I can set the correct CultureInfo() at the start of the program, but is there another way? Thanks. cheers, roel

    W 1 Reply Last reply
    0
    • R roel_

      Hi, I can translate my application using the procedure described in the MSDN article 'Walkthrough: Localizing Windows Forms'. In that article, one one language is set, by instantiating a CultureInfo() in the constructor of the from and setting it on the current thread's CurrentUICulture. But now, how do I dynamically (at run time) change the language that the UI is show in? I've tried calling InitializeComponent() after setting Thread.CurrentThread.CurrentUICulture but that doesn't work. I know I can have the user close the application and restart it so that I can set the correct CultureInfo() at the start of the program, but is there another way? Thanks. cheers, roel

      W Offline
      W Offline
      WillemM
      wrote on last edited by
      #2

      You can set the currentculture property of the thread your in. Thread.CurrentThread.CurrentCulture = New CultureInfo("nl-NL", False)

      R 1 Reply Last reply
      0
      • W WillemM

        You can set the currentculture property of the thread your in. Thread.CurrentThread.CurrentCulture = New CultureInfo("nl-NL", False)

        R Offline
        R Offline
        roel_
        wrote on last edited by
        #3

        Hi, Thanks, but that only works when doing it before the UI is created. I'd like to change the language of the labels, buttons etc. while the application is already running (through a menu option). cheers, roel

        R 1 Reply Last reply
        0
        • R roel_

          Hi, Thanks, but that only works when doing it before the UI is created. I'd like to change the language of the labels, buttons etc. while the application is already running (through a menu option). cheers, roel

          R Offline
          R Offline
          Rob Graham
          wrote on last edited by
          #4

          If you put the different language versions of your lable text etc. into separate resource files, you can change them on the fly by reloading the appropriate resource file and modifying the appropriate text yourself. Load the initial resource file at startup using the current culture, then reload when the user changes the language selection. A little painful, as you will have to manage retrieving all the appropriate strings by key, and updating the pertinent controls yourself, but it will work. Absolute faith corrupts as absolutely as absolute power Eric Hoffer All that is necessary for the triumph of evil is that good men do nothing. Edmund Burke

          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