Search code examples
.netlocalizationcultureinfo

What might cause CurrentCulture and CurrentUICulture to default to a value other than the apparent system culture?


I have a WinForms based application using the .NET 3.5 framework. The application has localized versions of some resources.

When I run the application on a machine running a copy of Windows XP which was originally installed with en-US as the default culture, but has subsequently had the default culture set to en-CA, both CurrentCulture and CurrentUICulture are defaulting to en-US.

Why might this be happening? What do I need to change so that the application starts using the current OS culture as its default?


Solution

  • User never mentions her favorite language per se in Windows settings: She sets her culture in Control Panel, such English (Canada) aka en-CA. This choice is reflected by the Thread.Culture property. It is used by Windows to determine how to display and format things such as dates (including format and names of days and months), currencies,...

    The other setting is the language in which Windows (GUI) was installed (Most likely English (United States) in your case). This is reflected by Thread.CurrentUICulture. There are of course way less available choices for this one since it reflects the language of the GUI (menus, buttons, help,...). e.g. no such thing as en-CA CurrentUICulture.

    Note: In Vista+ and XP-MUI, you can subsequently install additional GUI languages and set the language to be used for each user account. This is reflected in CurrentUICulture.

    A common misconception is to believe that Culture should be used to determine user's favorite language. It is better to rely on CurrentUICulture. In my case, Windows is in English and my user preference (Culture) is fr-BE (French - Belgium). Don't ever think of displaying your UI in French: I installed Windows in English for a purpose: I'd rather have a native UI in English rather than a translated one in French. The reasons behind my choice are arguable but this is irrelevant. Only my decision is relevant.

    That said, I read 5/2/2012 as Feb 5th 2012 rather than May 2nd. That's why fr-BE is my locale/Culture.

    FWIW, Language for non-Unicode Programs says which default codepage (CP_ACP in Win32 NLS parlance)should be used by non Unicode programs. This doesn't affect your app since .NET apps are Unicode.

    Default Input Language determines the default keyboard layout. This is not the Culture setting neither.

    The setting that affects the Culture property is this one:

    XP Regional Settings