Add keyboard language to Windows 10 with PowerShell

Most of the world lives outside the US or UK which means that we usually have a different keyboard layout on our computer. This means that we often want to have Windows display language in one language and the keyboard layout in another language.

The following code will set the UI language to German and the keyboard layout to Swedish. Strange combination, right? :P

$ccode = "de-DE"
$langList = New-WinUserLanguageList $ccode
$langList[0].InputMethodTips.Clear()
$langList[0].InputMethodTips.Add('0407:0000041d')
Set-WinUserLanguageList -Force $langList
Set-WinSystemLocale $ccode

de-DE is the Windows display language. If you change this Windows Update may start downloading “Typing”, “Optical character recognition” and “Speech recognition”.
InputMethodTips.Clear() Will clear any keyboard layout you may already have.
0409 is the Windows display language code. You can find a list of codes for each country here. Just look for the “Hex” code.
0000041d is the KLID (keyboard layout identifier). You can find a list of available identifiers here.

If you already have the language pack downloaded, all you have to do is log out and in again. If you do not have the language pack for the display language Windows Update will let you know that “a language pack is available” in Settings or you can manually download and install it prior to running the script.

If you want to download the display language in advance you can go to this site and download the .cab file. Then you can run the following command as admin. Just make sure to change the directory and the cab-file name.

DISM /Online /Add-Package /PackagePath:C:\Users\User\Desktop\lp_06eb7bde168ca27d694d85bcde58fe1d9a5284ea.cab

The advantage of manually installing the display language is that you will not have to wait for Windows Update to get the display language, and if you use the code above, you the change will be applied immediately. You will still have to wait for Windows Update to get “Typing/optical/speech” though, but that is OK because those changes will be automatically handled.

Examples

Norwegian input, English display language

$ccode = "nb-NO"
$langList = New-WinUserLanguageList $ccode
$langList[0].InputMethodTips.Clear()
$langList[0].InputMethodTips.Add('0409:00000414')
Set-WinUserLanguageList -Force $langList
Set-WinSystemLocale $ccode

Swedish input, English display language

$ccode = "sv-SE"
$langList = New-WinUserLanguageList $ccode
$langList[0].InputMethodTips.Clear()
$langList[0].InputMethodTips.Add('0409:0000041d')
Set-WinUserLanguageList -Force $langList
Set-WinSystemLocale $ccode

To get the number code for your language you can visit this link


Sources:

http://drizin.io/Change-Keyboard-Input-Languages-with-Powershell/

https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/default-input-locales-for-windows-language-packs

https://www.autoitscript.com/autoit3/docs/appendix/OSLangCodes.htm

https://www.tenforums.com/tutorials/30656-see-default-system-language-windows-10-a.html

https://superuser.com/questions/1309399/change-display-language-in-windows-10-with-cmd-or-powershell-commands/1310632#1310632