From f095593cd5a939708c7b00a00551cfabde05584b Mon Sep 17 00:00:00 2001 From: Eberhard Beilharz Date: Thu, 6 Jul 2023 20:04:23 +0200 Subject: [PATCH] fix(windows): Adjust to new version of langtags.json The new version of `langtags.json` added a new `_conformance` record at the top of the file. This change adjusts the indexes where we expect the `_version` record. It also introduces a const for the index of the version record to make future updates easier. --- .../Keyman.System.BuildLangTags.pas | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/common/windows/delphi/tools/build_standards_data/Keyman.System.BuildLangTags.pas b/common/windows/delphi/tools/build_standards_data/Keyman.System.BuildLangTags.pas index aecb1a9dcb..037a78fd83 100644 --- a/common/windows/delphi/tools/build_standards_data/Keyman.System.BuildLangTags.pas +++ b/common/windows/delphi/tools/build_standards_data/Keyman.System.BuildLangTags.pas @@ -7,6 +7,10 @@ type class procedure Build(const LangTagsFile, DestinationFile: string); end; +const + { Index of the _version record in the langtags.json file } + IndexOfVersionRecord = 3; + implementation uses @@ -85,7 +89,7 @@ begin end; try - for i := 0 to 2 do + for i := 0 to IndexOfVersionRecord do begin if (FLangTags.Items[i] as TJSONObject).Values['tag'].Value = '_version' then begin @@ -153,11 +157,11 @@ begin FResult.Add(''); FResult.Add('{ TLangTagsMap }'); FResult.Add(''); - FResult.Add(Format('const CLangTags: array[0..%d] of TLangTag = (', [FLangTags.Count - 4])); + FResult.Add(Format('const CLangTags: array[0..%d] of TLangTag = (', [FLangTags.Count - IndexOfVersionRecord - 2])); comma := ','; FTagMapCount := 0; - for i := 3 to FLangTags.Count - 1 do + for i := IndexOfVersionRecord + 1 to FLangTags.Count - 1 do begin if i = FLangTags.Count - 1 then comma := ''; FLangTag := FLangTags.Items[i] as TJSONObject; @@ -194,7 +198,7 @@ begin FResult.Add(Format('const CAllTags: array[0..%d] of TStringMap = (', [FTagMapCount-1])); comma := ''; - for i := 3 to FLangTags.Count - 1 do + for i := IndexOfVersionRecord + 1 to FLangTags.Count - 1 do begin FLangTag := FLangTags.Items[i] as TJSONObject;