From 9afc8563ce8a51c4b4f05ec1d3ffe10706f75bd7 Mon Sep 17 00:00:00 2001 From: Arjan Mels Date: Sun, 22 Dec 2024 19:31:22 +0100 Subject: [PATCH] CLDR-11874 Add conversion of subdivisions to json --- .../java/org/unicode/cldr/json/Ldml2JsonConverter.java | 8 ++++++-- .../java/org/unicode/cldr/json/LdmlConvertRules.java | 3 +-- .../org/unicode/cldr/json/JSON_config_subdivisions.txt | 10 ++++++++++ .../org/unicode/cldr/json/JSON_config_supplemental.txt | 1 + 4 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 tools/cldr-code/src/main/resources/org/unicode/cldr/json/JSON_config_subdivisions.txt diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/json/Ldml2JsonConverter.java b/tools/cldr-code/src/main/java/org/unicode/cldr/json/Ldml2JsonConverter.java index d4e01927d6f..b9f0a65cb92 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/json/Ldml2JsonConverter.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/json/Ldml2JsonConverter.java @@ -102,7 +102,8 @@ enum RunType { annotations, annotationsDerived, bcp47(false, false), - transforms(false, false); + transforms(false, false), + subdivisions(false, true); private final boolean isTiered; private final boolean hasLocales; @@ -748,6 +749,8 @@ private int convertCldrItems( outFilename = filename + ".json"; } else if (type == RunType.transforms) { outFilename = filename + ".json"; + } else if (type == RunType.subdivisions) { + outFilename = filename + ".json"; } else if (js.section.equals("other")) { // If you see other-___.json, it means items that were missing from // JSON_config_*.txt @@ -786,7 +789,8 @@ private int convertCldrItems( } } else if (type == RunType.rbnf || type == RunType.bcp47 - || type == RunType.transforms) { + || type == RunType.transforms + || type == RunType.subdivisions) { // untiered, just use the name js.packageName = type.name(); tier = ""; diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/json/LdmlConvertRules.java b/tools/cldr-code/src/main/java/org/unicode/cldr/json/LdmlConvertRules.java index ccdd7b3404e..7aca50e4948 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/json/LdmlConvertRules.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/json/LdmlConvertRules.java @@ -18,8 +18,7 @@ class LdmlConvertRules { /** File sets that will not be processed in JSON transformation. */ public static final ImmutableSet IGNORE_FILE_SET = - ImmutableSet.of( - "attributeValueValidity", "coverageLevels", "postalCodeData", "subdivisions"); + ImmutableSet.of("attributeValueValidity", "coverageLevels", "postalCodeData"); /** * The attribute list that should become part of the name in form of name-(attribute)-(value). diff --git a/tools/cldr-code/src/main/resources/org/unicode/cldr/json/JSON_config_subdivisions.txt b/tools/cldr-code/src/main/resources/org/unicode/cldr/json/JSON_config_subdivisions.txt new file mode 100644 index 00000000000..97051e09f8c --- /dev/null +++ b/tools/cldr-code/src/main/resources/org/unicode/cldr/json/JSON_config_subdivisions.txt @@ -0,0 +1,10 @@ +# Processed by LdmlConfigFileReader + +# These are earlier in the file to keep the packageDesc in one place. +package=subdivisions ; packageDesc=Translated versions of locale display name elements: subdivisions. + +# mapping paths to sections +section=subdivisions ; path=//cldr/subdivisions/[^/]++/localeDisplayNames/subdivisions/.* ; package=subdivisions + +# Depedencies +dependency=core ; package=subdivisions diff --git a/tools/cldr-code/src/main/resources/org/unicode/cldr/json/JSON_config_supplemental.txt b/tools/cldr-code/src/main/resources/org/unicode/cldr/json/JSON_config_supplemental.txt index 66042098b28..cfab58eb595 100644 --- a/tools/cldr-code/src/main/resources/org/unicode/cldr/json/JSON_config_supplemental.txt +++ b/tools/cldr-code/src/main/resources/org/unicode/cldr/json/JSON_config_supplemental.txt @@ -34,6 +34,7 @@ section=aliases ; path=//cldr/supplemental/metadata/alias/(language|script|subdi section=units ; path=//cldr/supplemental/(unitConstants|unitQuantities|convertUnits|unitPrefixes).* ; package=core section=unitsMetadata ; path=//cldr/supplemental/metadata/.*/(unitAlias|usageAlias).* ; package=core section=unitIdComponents ; path=//cldr/supplemental/unitIdComponents/.* ; package=core +section=subdivisionContainment ; path=//cldr/supplemental/subdivisionContainment/.* ; package=core # ignored items section=IGNORE ; path=//cldr/supplemental/metadata/serialElements.* ; package=IGNORE