LazUtils: simplify LazGetShortLanguageID procedure logic

It actually wants to return FallbackLang, so just return it and do not
make any assumptions about its length.
This commit is contained in:
Maxim Ganetsky 2023-06-03 19:18:40 +03:00
parent 68228adb4e
commit d05dd86b2c

View File

@ -4075,11 +4075,10 @@ begin
end;
{
This routine will strip country information from the language ID
making it more simple
This routine will return current short language ID (without the country code).
Ideally the resulting ID from here should conform to ISO 639-1
or ISO 639-2, if the language has no code in ISO 639-1
or ISO 639-2, if the language has no code in ISO 639-1.
}
procedure LazGetShortLanguageID(var Lang: String);
var
@ -4087,9 +4086,7 @@ var
begin
FallbackLang:='';
LazGetLanguageIDs(Lang, FallbackLang);
// Simply making sure its length is at most 2 should be enough for most languages
if Length(Lang) > 2 then Lang := Lang[1] + Lang[2];
Lang:=FallbackLang;
end;
{