Tutorial :detect os language from c#


Is there a way to detect the Language of the OS from within a c# class?


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.


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:

Get operating system language in c#.


"System.Globalization.CultureInfo.CurrentUICulture.DisplayName". This is exactly what you want.


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.


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


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



Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »