The Powershell API can provide information about locales related to the ones that have been installed which the registry does not. For instance after installing fr_FR one can also get the LCID and keyboard layout for fr_BE, fr_CH, etc. Add GetWinProperties() to standardize retrieving information from the SetWinLocale.ps1 script.
Signed-off-by: Francois Gouget fgouget@codeweavers.com --- testbot/bin/SetWinLocale | 40 ++++++++++++++-------------------------- 1 file changed, 14 insertions(+), 26 deletions(-)
diff --git a/testbot/bin/SetWinLocale b/testbot/bin/SetWinLocale index 29b57b30f8..73c774e6e4 100755 --- a/testbot/bin/SetWinLocale +++ b/testbot/bin/SetWinLocale @@ -43,7 +43,6 @@ use WineTestBot::Utils;
my $HKCU_INTERNATIONAL = "HKCU\Control Panel\International"; my $HKCU_GEO = "HKCU\Control Panel\International\Geo"; -my $HKCU_USER_PROFILE = "HKCU\Control Panel\International\User Profile";
# @@ -679,10 +678,11 @@ else FatalError("could not open '$0.ps1' for reading: $!\n"); }
-sub GetWinSettings() +sub GetWinProperties($) { - my $Cmd = ["powershell.exe", "-ExecutionPolicy", "ByPass", "-File", - "$name0.ps1", "settings"]; + my ($Cmd) = @_; + + Debug(Elapsed($Start), " Running: @$Cmd\n"); my $Ret = $TA->RunAndWait($Cmd, 0, 30, undef, "$name0.out", "$name0.out"); FatalError("failed to run @$Cmd: ", $TA->GetLastError(), "\n") if ($Ret < 0); my $Out = $TA->GetFileToString("$name0.out") if (!$Ret); @@ -705,6 +705,12 @@ sub GetWinSettings() return $Settings; }
+sub GetWinSettings() +{ + return GetWinProperties(["powershell.exe", "-ExecutionPolicy", "ByPass", + "-File", "$name0.ps1", "settings"]); +} + sub Value2Str($) { my ($Value) = @_; @@ -774,28 +780,10 @@ sub GetWinKeyboardIds($) { my ($Locale) = @_;
- # The locale information is sometimes stored in a key with a non-standard - # name, despite the standard locale name being used everywhere else! - my $Key = $LocaleInfoKeys{$Locale} || $Locale; - my $Values = RegGetValues("$HKCU_USER_PROFILE\$Key", "*:*"); - if (!%$Values) - { - $Key =~ s/-.*$//; - $Values = RegGetValues("$HKCU_USER_PROFILE\$Key", "*:*"); - } - - # Look for the locale's keyboard id(s). - my %WinLayouts; - foreach my $VName (keys %$Values) - { - # The value is the keyboard layout's preference order - $WinLayouts{hex($Values->{$VName})} = $VName if ($VName =~ /^[0-9A-F]{4}:/); - } - $WinKeyboardIds{$Locale} = %WinLayouts ? [] : $Keyboards{$Locale}; - foreach my $Index (sort { $a cmp $b } keys %WinLayouts) - { - push @{$WinKeyboardIds{$Locale}}, $WinLayouts{$Index}; - } + my $Info = GetWinProperties(["powershell.exe", "-ExecutionPolicy", "ByPass", + "-File", "$name0.ps1", "info", $Locale]); + $WinKeyboardIds{$Locale} = $Info->{InputMethodTips} ? [$Info->{InputMethodTips}] : $Keyboards{$Locale}; + Debug("WinKeyboardIds=", Value2Str($WinKeyboardIds{$Locale}), "\n"); if (!$WinKeyboardIds{$Locale}) { FatalError("could not find the $Locale LCID and keyboard ids. Maybe the locale is not installed?\n");