none
How to set the default culture Info for all thread of an application independant from the Windows UI language?

    Question

  • A classic 'european' topic?

    I am working with Windows7Pro in German, and VS2010 in English. I whish I had all exception handling in english.
    Thus, I set the explicly the current culture to english:
     var culture = new CultureInfo("en-us");
     Application.CurrentCulture = culture;
            Thread.CurrentThread.CurrentUICulture = culture;
            Thread.CurrentThread.CurrentCulture = culture;

    But I do still have some exception in German, because 'by design', .NET Framework considers the Windows UI language as default culture when a new thread in created (e.g. by GUI controls), as I read here http://www.dotnetmonster.com/Uwe/Forum.aspx/winform/14177/setting-culture-of-threads

    What is the motivation for such a design? It has always been a problem for us in Europe working with multi languages: it is quite difficult to ensure the software is working properly whereever it is rolled out.
    Is there a way to define the default culture of all children threads?

    Friday, September 24, 2010 9:24 AM

Answers

  • Frankly, no. When creating a Thread it is your job to make sure it has the correct Culture specified. And specifying a specific culture, other than the system defined one, is against the guidelines as you've already found out.

    To get around this, it's usually the best solution to set the culture of all things in the background to CultureInvariant and then specify the exact culture only when you're doing UI stuff. That way you should have the least amount of difficulties and you should always know what the correct thing to do is.

    The best way to ensure the default locale, is to configure the system accordingly. From Microsoft's perspective it is in the best interest of the user to show any application in the Language and Locale settings of their machine. 

    In your perspective it's best to show a working application to your user. In order to give the user that, you should not depend on locale specific things for your logic and you should specify which culture to use to display messages and to format data. There's even a number of CodeAnalysis (FxCop) rules that warn you when you're not doing things right from this perspective.

    Related reading material (which I'm sure you've found already):

    http://msdn.microsoft.com/en-us/library/ms973825.aspx

    http://msdn.microsoft.com/en-us/goglobal/bb688110.aspx

    • Marked as answer by eryang Friday, October 01, 2010 5:57 AM
    Friday, September 24, 2010 2:24 PM

All replies

  • Frankly, no. When creating a Thread it is your job to make sure it has the correct Culture specified. And specifying a specific culture, other than the system defined one, is against the guidelines as you've already found out.

    To get around this, it's usually the best solution to set the culture of all things in the background to CultureInvariant and then specify the exact culture only when you're doing UI stuff. That way you should have the least amount of difficulties and you should always know what the correct thing to do is.

    The best way to ensure the default locale, is to configure the system accordingly. From Microsoft's perspective it is in the best interest of the user to show any application in the Language and Locale settings of their machine. 

    In your perspective it's best to show a working application to your user. In order to give the user that, you should not depend on locale specific things for your logic and you should specify which culture to use to display messages and to format data. There's even a number of CodeAnalysis (FxCop) rules that warn you when you're not doing things right from this perspective.

    Related reading material (which I'm sure you've found already):

    http://msdn.microsoft.com/en-us/library/ms973825.aspx

    http://msdn.microsoft.com/en-us/goglobal/bb688110.aspx

    • Marked as answer by eryang Friday, October 01, 2010 5:57 AM
    Friday, September 24, 2010 2:24 PM
  • Hi KaiMohrhagen,

    May I know the issue status, does Jesse's reply  help?


    Sincerely,
    Eric
    MSDN Subscriber Support in Forum
    If you have any feedback of our support, please contact msdnmg@microsoft.com.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Tuesday, September 28, 2010 3:27 AM