Merge pull request #4563 from keymanapp/fix/developer/2998-package-compile-require-langugae-tag

fix(developer): require language tag when compiling keyboard package
This commit is contained in:
Marc Durdin 2021-03-03 09:28:07 +11:00 committed by GitHub
commit 16e5b9c358
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 30 deletions

View file

@ -41,7 +41,6 @@ uses
System.IniFiles,
System.Zip,
BCP47Tag,
OnlineConstants,
VisualKeyboard,
utilfiletypes,
@ -452,41 +451,17 @@ begin
end;
const
SKKeyboardPackageLanguageNonCanonical = 'The keyboard %0:s has a non-canonical language ID "%1:s" (%2:s), should be "%3:s".';
SKKeyboardPackageLanguageNonCanonical = 'The keyboard %0:s has a non-canonical language tag "%1:s" (%2:s), should be "%3:s".';
SKKeyboardShouldHaveAtLeastOneLanguage = 'The keyboard %0:s has no language tags. It should have at least one language tag.';
procedure TCompilePackage.CheckKeyboardLanguages;
var
k: TPackageKeyboard;
l: TPackageKeyboardLanguage;
NewID: string;
Tag, NewTag: TBCP47Tag;
begin
for k in pack.Keyboards do
begin
for l in k.Languages do
begin
Tag := TBCP47Tag.Create(l.ID);
NewID := TCanonicalLanguageCodeUtils.FindBestTag(l.ID, False, False);
if NewID = '' then
begin
// We don't have enough data to validate this tag
Continue;
end;
NewTag := TBCP47Tag.Create(NewID);
try
if (Tag.Script = '') and (NewTag.Script <> '') then
begin
// Only give non-canonical warning if the script tag is missing but should
// be present.
NewTag.Region := Tag.Region; // We don't care about region, don't give unhelpful info to developer
WriteMessage(plsWarning, Format(SKKeyboardPackageLanguageNonCanonical, [k.ID, l.ID, l.Name, NewTag.Tag]));
end;
finally
NewTag.Free;
Tag.Free;
end;
end;
if k.Languages.Count = 0 then
WriteMessage(plsWarning, Format(SKKeyboardShouldHaveAtLeastOneLanguage, [k.ID]));
end;
end;

View file

@ -209,7 +209,7 @@ begin
end
else if not TCanonicalLanguageCodeUtils.IsCanonical(tag, msg, False, False) then
begin
DoError(Format(SWarning_LanguageTagIsNotCanonical, [kbd.ID, lang.ID, msg]), plsWarning);
DoError(Format(SWarning_LanguageTagIsNotCanonical, [kbd.ID, lang.ID, msg]), plsInfo);
end;
finally
Free;