Converting Language IDs in Language Names

by Jul 29, 2022

In our previous mini series we showed different approaches to get to the names of installed OS languages using different PowerShell methods. The result was always a list of language IDs, similar to this one:

 
de-DE
en-US
fr-FR   

What if I needed to convert these to full country names? Fortunately, it is always just a matter of data types. All the methods we illustrated to get to the installed language packs returned string data. Let’s take the WMI example for simplicity:

$os = Get-CIMInstance -ClassName Win32_OperatingSystem
$os.MUILanguages 

When you cast the result to a better data type, you get better data. Instead of string, let’s take the data type responsible for county names: CultureInfo!

$os = Get-CIMInstance -ClassName Win32_OperatingSystem
[CultureInfo[]]$os.MUILanguages

Immediately, the same data is now represented in a much richer format:

 
LCID             Name             DisplayName          
----             ----             -----------         
1031             de-DE            German (Germany)
1033             en-US            English (United States)
1036             fr-FR            French (France)

 


Twitter This Tip! ReTweet this Tip!