From 9dcffdb9044f5301ec8bc7ed34e53c31b128e0cf Mon Sep 17 00:00:00 2001 From: Ross Date: Wed, 8 Jun 2022 15:35:59 +1000 Subject: [PATCH] fix(windows): BCP47tag is canonicalized in GetUserDefaultLanguage The BCP47tag is canonicalized in GetUserDefaultLanguage. Comments updated for the function to make developer aware. Comments added to GetKeyboardLanguage to make clear that it can actuall Add/Set a langague in the com object. --- .../Keyman.Configuration.System.TIPMaintenance.pas | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/windows/src/desktop/kmshell/install/Keyman.Configuration.System.TIPMaintenance.pas b/windows/src/desktop/kmshell/install/Keyman.Configuration.System.TIPMaintenance.pas index 542232dde1..5595ba073e 100644 --- a/windows/src/desktop/kmshell/install/Keyman.Configuration.System.TIPMaintenance.pas +++ b/windows/src/desktop/kmshell/install/Keyman.Configuration.System.TIPMaintenance.pas @@ -32,13 +32,15 @@ type class function GetFirstLanguage(Keyboard: IKeymanKeyboardInstalled): string; overload; class function GetFirstLanguage(Keyboard: IKeymanKeyboardFile): string; overload; - /// Get the BCP47 tag for the user's default language + /// Get the canonicalized BCP47 tag for the user's default language class function GetUserDefaultLanguage: string; overload; static; class procedure GetUserDefaultLanguage(var BCP47: string; var LangID: Integer); overload; static; - /// Get the -default-lang parameter string for kmshell + /// Get the canonicalized -default-lang parameter string for kmshell class function GetUserDefaultLangParameterString: string; static; private + // Get the IKeymanKeyboardLanguageInstalled Object corresponding to the BCBP47Tag or **Add** it if not found for the supplied KeyboardID. + // Returns Nil if no Keyboard is found with the supplied KeyboardID. class function GetKeyboardLanguage(const KeyboardID, BCP47Tag: string): IKeymanKeyboardLanguageInstalled; static; end; @@ -342,7 +344,7 @@ begin if r.OpenKeyReadOnly('\' + SRegKey_ControlPanelInternationalUserProfile + '\' + key) and r.ValueExists(v) then begin - BCP47 := key; + BCP47 := (kmcom as IKeymanBCP47Canonicalization).GetCanonicalTag(key); LangID := GetLangIDFromValueName; Break; end; @@ -359,7 +361,7 @@ begin r.ReadMultiString(SRegValue_CPIUP_Languages, tags); if tags.Count > 0 then begin - BCP47 := tags[0].Trim; + BCP47 := (kmcom as IKeymanBCP47Canonicalization).GetCanonicalTag(tags[0].Trim); if r.OpenKeyReadOnly('\' + SRegKey_ControlPanelInternationalUserProfile + '\' + BCP47) then LangID := GetLangIDFromValueName; end;