Browse Source

Fix the error of Chinese system getting language information under Windows system

ACTom 2 years ago
parent
commit
c39a9ffad3
1 changed files with 7 additions and 1 deletions
  1. 7 1
      packages/fcl-base/src/gettext.pp

+ 7 - 1
packages/fcl-base/src/gettext.pp

@@ -295,14 +295,20 @@ begin
   Lang := '';
   FallbackLang:='';
   UserLCID := GetUserDefaultLCID;
-  if GetLocaleInfo(UserLCID, LOCALE_SABBREVLANGNAME, @Buffer[1], 4)<>0 then
+  if GetLocaleInfo(UserLCID, LOCALE_SABBREVLANGNAME, @Buffer[1], 4)<>0 then begin
     FallbackLang := lowercase(copy(Buffer,1,2));
+
+    // Chinese abbreviation should be zh instead of ch
+    if (Copy(Buffer,1,3)='CHS') or (Copy(Buffer,1,3)='CHT') then FallbackLang:='zh';
+  end;
   if GetLocaleInfo(UserLCID, LOCALE_SABBREVCTRYNAME, @Buffer[1], 4)<>0 then begin
     Country := copy(Buffer,1,2);
 
     // some 2 letter codes are not the first two letters of the 3 letter code
     // there are probably more, but first let us see if there are translations
     if (Buffer='PRT') then Country:='PT';
+    
+    if (Copy(Buffer,1,3)='CHN') then Country:='CN';  
 
     Lang := FallbackLang+'_'+Country;
   end;