From d05dd86b2ccf8c357afef64f3a891a8ba809b929 Mon Sep 17 00:00:00 2001 From: Maxim Ganetsky Date: Sat, 3 Jun 2023 19:18:40 +0300 Subject: [PATCH] LazUtils: simplify LazGetShortLanguageID procedure logic It actually wants to return FallbackLang, so just return it and do not make any assumptions about its length. --- components/lazutils/lazutf8.pas | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/components/lazutils/lazutf8.pas b/components/lazutils/lazutf8.pas index 942780fa6c..031e9deae6 100644 --- a/components/lazutils/lazutf8.pas +++ b/components/lazutils/lazutf8.pas @@ -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; {