Is there a way to detect the Language of the OS from within a c# class?
7 Answers
Unfortunately, the previous answers are not 100% correct.
The CurrentCulture
is the culture info of the running thread, and it is used for operations that need to know the current culture, but not do display anything. CurrentUICulture
is used to format the display, such as correct display of the DateTime
.
Because you might change the current thread Culture
or UICulture
, if you want to know what the OS CultureInfo
actually is, use CultureInfo.InstalledUICulture
.
Also, there is another question about this subject (more recent than this one) with a detailed answer:

- 1
- 1

- 434
- 4
- 5
-
1That's not right either. `CurrentCulture` is used for formatting dates and numbers and such, and `CurrentUICulture` is used to look up resources. – Sven Jun 09 '11 at 13:39
-
No Sven, in this one, you are actually wrong and Mihai has written the correct thing: the CultureInfo.InstalledUICulture seems to be the actual OperatingSystem's predefined culture info. I've just checked at http://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo.installeduiculture.aspx and they are clearly saying that this is the system-default one! – quetzalcoatl Nov 03 '11 at 16:53
-
1Not true quetzalcoati, sven is right. If I change the Date, Time and Number formats in control panel this will change CurrentCulture, It will not change CurrentUICulture. CurrentUICulture is used or should be used to display the UI elements. Please do not use CurrentCulture for this as an end-user might want to display numbers different but still wants an otherwise consistent UI. She couldn't be bothered with the Installed culture though. – theking2 Dec 24 '14 at 21:17
With the System.Globalization.CultureInfo
class you can determine what you want.
With CultureInfo.CurrentCulture
you get the system set culture, with CultureInfo.CurrentUICulture
you get the user set culture.

- 9,018
- 9
- 42
- 48
-
15Your description of the two properties is wrong. `CultureInfo.CurrentCulture` is the culture that is used to format dates, numbers, etc. and is initialized from the users locale (regional settings). `CultureInfo.CurrentUICulture` is the culture used by the resource manager to look up string resources, and is initialized from the OS's UI language. – Sven Jun 09 '11 at 13:38
-
Sven pointed out the problem correctly, but the actual answer is elsewhere. Please see the Mihai's answer below and the link to MSDN I've included in a comment – quetzalcoatl Nov 03 '11 at 16:55
"System.Globalization.CultureInfo.CurrentUICulture.DisplayName"
. This is exactly what you want.

- 12,007
- 32
- 121
- 193
Means that if the system locale on Region and Language, you can use Win32 API function GetSystemDefaultLCID. The signiture is as follow:
[DllImport("kernel32.dll")]
static extern uint GetSystemDefaultLCID();
GetSystemDefaultLCID function returns the LCID. It can map language string from the folowing table. Locale IDs Assigned by Microsoft

- 61
- 1
Do you mean whether the machine is configured (e.g.) with English, French or Japanese?
Have a look at the CultureInfo class - particularly CurrentCulture, which is initialised from the OS current regional settings.

- 43,618
- 10
- 81
- 133
-
I think we are on the same page but to precisely answer what he is asking: the answer is "System.Globalization.CultureInfo.CurrentUICulture.DisplayName" – Lost Sep 16 '13 at 19:09
-
Have a look instead at CurrentUICulture instead. CurrentCulture is not really what you want. (See my comments above) – theking2 Dec 24 '14 at 21:23
All of the answers above seem to only get you the OS installed culture (at best). I ran into an issue where I needed the actual display language being used in Windows. i.e. the user installed the default en-US Windows install, but then added a language pack for German (de-DE) and set that as their display language.
To get that, I used System.Windows.Input.InputLanguageManager.Current.CurrentInputLanguage

- 5,511
- 1
- 28
- 38
System.Threading.Thread.CurrentThread.CurrentCulture