Sometimes it is required to set the UI language of the session to a special language for a specific user or app.
For this you have to follow these steps:
- Install the required language(s) in Windows:
Hint: Don't download more than one language at the time, otherwise Windows update sometimes stuck
- Create a StartupBefore.ps1 file in c:\ProgramData\Cameyo with the following content (or add it to your existing, if any):
Add-Type @" using System; using System.Runtime.InteropServices; public class User32 { [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] public static extern int SendMessageTimeout(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam, SendMessageTimeoutFlags fuFlags, uint uTimeout, out IntPtr lpdwResult); public const uint WM_SETTINGCHANGE = 0x001A; [Flags] public enum SendMessageTimeoutFlags : uint { SMTO_NORMAL = 0x0000, SMTO_BLOCK = 0x0001, SMTO_ABORTIFHUNG = 0x0002, SMTO_NOTIMEOUTIFNOTHUNG = 0x0008 } public static void RefreshSettings() { IntPtr result; SendMessageTimeout(IntPtr.Zero, WM_SETTINGCHANGE, IntPtr.Zero, IntPtr.Zero, SendMessageTimeoutFlags.SMTO_NORMAL, 100, out result); } } "@ if ($env:CAMEYO_UILANGUAGE -ne $null) { $language = $env:CAMEYO_UILANGUAGE Set-ItemProperty -Path 'HKCU:\Control Panel\Desktop' -Name 'PreferredUILanguages' -Value $language Set-ItemProperty -Path 'HKCU:\Control Panel\International' -Name 'LocaleName' -Value $language Set-ItemProperty -Path 'HKCU:\Control Panel\International\User Profile' -Name 'Languages' -Value $language [User32]::RefreshSettings() }
- Get the language code(s) [LanguageTag] with the following PowerShell command:
Get-WinUserLanguageList
- Set the following PowerTag on the user/app/...
!UILANGUAGE=sv-SE
- You will see the software in the UI language (if the software supports it!)