Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is my CurrentCulture en-GB and my CurrentUICulture en-US

I have a C# application which has to run on machines with different culture settings. No problem I thought, it will just lookup on start up what the current culture is on the machine, and do everything for me. Well no, it would seam that something is not quite right.

I have a Windows XP machine with everything in Regional and Language options set to English US, yet when my application starts up it reports that my CurrentCulture is en-GB and my CurrentUICulture is en-US.

How can I get my program to just use whatever the PC is set to ?

This is a Windows Service application if it makes any difference.

Thanks

like image 881
SnAzBaZ Avatar asked Nov 13 '09 23:11

SnAzBaZ


People also ask

How do I change the current culture in Visual Studio?

CurrentCulture = New CultureInfo("th-TH", False) Console. WriteLine("CurrentCulture is now {0}.", CultureInfo.CurrentCulture.Name) ' Display the name of the current UI culture. Console. WriteLine("CurrentUICulture is {0}.", CultureInfo.CurrentUICulture.Name) ' Change the current UI culture to ja-JP.

What is difference between CurrentCulture and CurrentUICulture?

CurrentCulture is the . NET representation of the default user locale of the system. This controls default number and date formatting and the like. CurrentUICulture refers to the default user interface language, a setting introduced in Windows 2000.

What is CultureInfo?

The CultureInfo class provides culture-specific information, such as the language, sublanguage, country/region, calendar, and conventions associated with a particular culture. This class also provides access to culture-specific instances of the DateTimeFormatInfo, NumberFormatInfo, CompareInfo, and TextInfo objects.

What is default culture in C#?

NET Framework 4 and previous versions, by default, the culture of all threads is set to the Windows system culture.


2 Answers

I believe the following is true:

  • CurrentCulture (which affects number and date formats) will reflect the regional settings of the account under which your application runs. You can change this easily with Control Panel / Regional Settings for the current user, and if you are an administrator also for the "default" user which is used for system accounts that are often used for Windows Services. To change the default user there's a "Use as Default" button somewhere.

  • CurrentUICulture will correspond to the language of the version of Windows you are using. For MUI versions, you can change this in Control Panel, but not for single-language versions.

like image 156
Joe Avatar answered Nov 02 '22 23:11

Joe


A Windows Service usually doesn't run under your UserAccount and then it doesn't matter what your regional settings are. It's about the regional settings of the System account. I'm guessing you run a en-GB version of Windows, and the system account still uses that.

There are ways to get at that account, check SuperUser.

like image 22
Henk Holterman Avatar answered Nov 03 '22 00:11

Henk Holterman