It returns Windows' 'canonical' locale identifier as well as the default keyboard layout.
Signed-off-by: Francois Gouget fgouget@codeweavers.com --- testbot/bin/SetWinLocale.ps1 | 50 ++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+)
diff --git a/testbot/bin/SetWinLocale.ps1 b/testbot/bin/SetWinLocale.ps1 index ed8fa29ee1..26bd03fdfd 100644 --- a/testbot/bin/SetWinLocale.ps1 +++ b/testbot/bin/SetWinLocale.ps1 @@ -103,6 +103,52 @@ function ShowSettings() exit 0 }
+function GetLocaleInfo($Locale) +{ + $LInfo= New-WinUserLanguageList $Locale + $LInfo = $LInfo[0] + + # Window synthesizes an Autonym for unknown/uninstalled locales (e.g. fr-DE), + # but cannot recommend a keyboard layout. + # Note also that installing a locale (e.g. fr-FR) typically also installs + # (at least the core functionality of) related locales (e.g. fr-BE), even + # though those are not shown as installed in the GUI. + if ($LInfo.InputMethodTips[0] -eq $null) + { + return $null + } + + # 'Canonicalize' the LanguageTag by picking the matching entry from the + # installed languages list. + $List = Get-WinUserLanguageList + foreach ($L in $List) + { + if ($LInfo.Autonym -eq $L.Autonym) + { + return $L + } + } + return $LInfo +} + + +function ShowLocaleInfo($Argv) +{ + $Locale = $Argv[1] +GetLocaleInfo($Locale) + $LInfo = GetLocaleInfo($Locale) + if ($LInfo -eq $null) + { + echo "$Name0:error: unknown locale $Locale. Is it installed?" + exit 1 + } + + Write-Output "LanguageTag=$($LInfo.LanguageTag)" + Write-Output "Autonym=$($LInfo.Autonym)" + Write-Output "LocalizedName=$($LInfo.LocalizedName)" + Write-Output "InputMethodTips=$($LInfo.InputMethodTips)" + exit 0 +}
# # Modify the Windows locales settings through intl.cpl @@ -309,6 +355,7 @@ function SetLocales($Argv) function ShowUsage() { Write-Output "Usage: $Name0 settings" + Write-Output "or $Name0 info LOCALE" Write-Output "or $Name0 intlconfig LOCALE COUNTRYID SYSTEM UTF8 MUI KEYBOARDID SYSCOPY DEFCOPY" Write-Output "or $Name0 locales LOCALE COUNTRYID SYSTEM UTF8 MUI KEYBOARDID SYSCOPY DEFCOPY USEINTLCPL" Write-Output "or $Name0 -?" @@ -317,6 +364,8 @@ function ShowUsage() Write-Output "" Write-Output "Where:" Write-Output " settings Show the current Windows locale settings." + Write-Output " info Show information about the specified locale. In particular it" + Write-Output " shows Windows' 'canonical' locale identifier." Write-Output " intlconfig Generates an XML configuration file for intl.cpl." Write-Output " locales Modifies the locales either through the Powershell APIs or" Write-Output " intl.cpl." @@ -341,6 +390,7 @@ function ShowUsage()
$Action = $args[0] if ($Action -eq "settings") { ShowSettings } +if ($Action -eq "info") { ShowLocaleInfo $args } if ($Action -eq "intlconfig") { ShowIntlConfig $args } if ($Action -eq "locales") { SetLocales $args } $Rc = 0