locked
localizing does not work in release mode RRS feed

  • Question

  • Hello all,

    Why is my program only localizing when I compile in debug mode? What follows is some code that I put before the IntializeComponent() in the Form1 constructor:

    #if DEBUG
                Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr-FR"); //Form shows in French.
    #else
                //Thread.CurrentThread.CurrentUICulture = CultureInfo.InstalledUICulture; //Form shows in English.
                //Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture; //Form shows in English.
                //Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture; //Form shows in English.
                Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR"); //FORM SHOWS IN ENGLISH!!!
                MessageBox.Show(Thread.CurrentThread.CurrentUICulture.Name);
    #endif
    Thank you in advance.
    Monday, May 7, 2012 2:45 PM

Answers

  • Hello all,

    My fault.  I didn't know to include the resources.dll files when I installed.  That's why the installs reverted to English while the Debug version always seemed to work.

    Thanks anyway,

    Trufaux

    • Marked as answer by Lisa Zhu Friday, May 11, 2012 9:01 AM
    Monday, May 7, 2012 8:00 PM

All replies

  • Hi, 

    Since you are setting ThreadUI culture only if it is in debug mode using preprocessor #if DEBUG.

    setting CurrentUICulture drives to load right resource file. i.e CurrentUICulture is for localization (translation). so from your code remove the #if DEBUG preprocessor condition.

    Hope this helps you...


    If this post answers your question, please click "Mark As Answer". If this post is helpful please click "Mark as Helpful".

    Monday, May 7, 2012 6:06 PM
  • Hello Kris444,

    Your suggestion did not seem to help.

    Thread.CurrentThread.CurrentUICulture = CultureInfo.CurrentCulture; //Does nothing.
    #if DEBUG
                Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr-FR"); //Works great!!!
    #endif
                InitializeComponent();
                MessageBox.Show(Thread.CurrentThread.CurrentUICulture.Name); //Reports "en-US" on my computer, "fr-FR" on French computers.
    Even if I take out the preprocessor command, it does not help.
    Monday, May 7, 2012 7:14 PM
  • Try the code below

     public Form1()
            {
               
                InitializeComponent();
                Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr-FR"); //Montre le formulaire en français, !!!
                MessageBox.Show(Thread.CurrentThread.CurrentUICulture.Name);
            }


    Regards,
    Ahmed Ibrahim
    SQL Server Setup Team
    This posting is provided "AS IS" with no warranties, and confers no rights. Please remember to click "Mark as Answer" and "Vote as Helpful" on posts that help you.
    This can be beneficial to other community members reading the thread.

    Monday, May 7, 2012 7:27 PM
  • Hello all,

    My fault.  I didn't know to include the resources.dll files when I installed.  That's why the installs reverted to English while the Debug version always seemed to work.

    Thanks anyway,

    Trufaux

    • Marked as answer by Lisa Zhu Friday, May 11, 2012 9:01 AM
    Monday, May 7, 2012 8:00 PM