How can we get current operating system language using Win32_OperatingSystem Class and OSLanguage variable in c#? Thanks..
4 Answers
Like this:
static int Main( string[] argv )
{
CultureInfo ci = CultureInfo.InstalledUICulture ;
Console.WriteLine("Default Language Info:" ) ;
Console.WriteLine("* Name: {0}" , ci.Name ) ;
Console.WriteLine("* Display Name: {0}" , ci.DisplayName ) ;
Console.WriteLine("* English Name: {0}" , ci.EnglishName ) ;
Console.WriteLine("* 2-letter ISO Name: {0}" , ci.TwoLetterISOLanguageName ) ;
Console.WriteLine("* 3-letter ISO Name: {0}" , ci.ThreeLetterISOLanguageName ) ;
Console.WriteLine("* 3-letter Win32 API Name: {0}" , ci.ThreeLetterWindowsLanguageName ) ;
return 0 ;
}

- 71,308
- 16
- 93
- 135
-
6For example, I installed Windows 7 in English. Later I decided to download the UI translation of another language and configure that as my session lang and the new account default lang. I want my app, when the config file is not present and it is being created (probably during first run or install) to display texts on that secondary language, not English. Should I use InstalledUICulture or CurrenUICulture? – Hatoru Hansou Jan 23 '14 at 01:22
-
CurrentUI is a (much more recent) users decision. so you should go with that. – theking2 Feb 21 '19 at 20:07
-
This does not give you the Windows default display language, it gives you the user's region instead which is wrong if you want to use this data for translation purposes. – lukad May 21 '20 at 10:36
-
2@lukad: you might want to **[read the documentation for `CultureInfo.InstalledUICulture`](https://learn.microsoft.com/en-us/dotnet/api/system.globalization.cultureinfo.installeduiculture?view=netframework-4.8)** — where it is defined as "_The `CultureInfo` that represents the culture installed with the operating system . . .In a localized operating system, such as a Japanese edition of Windows, this property returns the culture of the operating system. This property is the equivalent of `GetSystemDefaultUILanguage` in the Windows API._" – Nicholas Carey May 21 '20 at 23:33
-
1@NicholasCarey Thanks Nicholas. Times have changed and I have to confess your answer surpasses completeness (and mine :-) ) got you a upvote – theking2 Oct 12 '21 at 18:21
Perhaps to make this a bit clearer (or not) the three cultures Installed, CurrentUI and Current are set in a not so obvious way.
If in the Control panel on a English UK system (Windows 10 Technical Preview) I specify a German (Swiss) date / time format the output of the following program:
CultureInfo ci = CultureInfo.InstalledUICulture;
Console.WriteLine("Installed Language Info:{0}", ci.Name);
ci = CultureInfo.CurrentUICulture;
Console.WriteLine("Current UI Language Info: {0}", ci.Name);
ci = CultureInfo.CurrentCulture;
Console.WriteLine("Current Language Info: {0}", ci.Name);
is thus:
Installed Language Info:en-GB
Current UI Language Info: en-GB
Current Language Info: de-CH
Meaning that Installed cannot be influenced but is set at install, but CurrentUI and Current can differ. Where CurrentUI probable means the localization of the OS (language settings) and Current only says something about how numbers dates and time is displayed (regional settings).
To often have I come across installation programs that take Current for the preferred language where it would probably give a more consistent end-user experience if instead CurrentUI was used.

- 2,174
- 1
- 27
- 36
-
3Also the "installed Culture" is important for certain things. I.E. the builtin-Account names: English: "BUILTIN\Administrators" vs. German "VORDEFINIERT\Administratoren". No matter which language the user is actual USING, those Names follow the installed-culture-localization. – dognose Oct 11 '21 at 10:01
using System;
class Program {
static void Main(string[] args) {
Console.WriteLine("You are speaking {0}",
System.Globalization.CultureInfo.CurrentCulture.EnglishName);
Console.ReadLine();
}
}

- 922,412
- 146
- 1,693
- 2,536
-
2Not quite. This only presents the locale the application is currently using. It MAY be the system's default, but does not need to be. We usually write bilingual apps, native-and-english, and really, the Current is just CURRENT setting, which governs how the application looks for localized resources. It may be easily changed, even at runtime. Nicholas' answer points to the correct thing (I mean, regarding the original poster's question. no doubt your code is OK, it just checks a different thing) -> http://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo.installeduiculture.aspx – quetzalcoatl Nov 03 '11 at 17:01
-
Well, clearly if the user changed the system locale then she's not speaking the same language anymore. – Hans Passant May 08 '12 at 17:06
-
2No, Hans. I am not a native English speaker, but I prefer to use the OS and all applications in English. However, I do change the system locale to benefit from regional date/time and number formatting. It's inconsistent and annoying when software looks at my current locale and attempts to display resources in my native language. – Ishmaeel Dec 21 '12 at 13:39
-
That's like going on vacation in China and expecting everybody to understand you when you speak Swahili. That only produces a lot of annoyed Chinese. If your software doesn't have the equivalent of Visual Studio's Tools + Options, Environment, International Settings, Language then you'll need to shop for better software. – Hans Passant Dec 21 '12 at 13:52
Don't mistake locales for UI language. Locales are about formatting numbers and dates and such. Also, there are independent settings for OS and for Apps.

- 1