diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/util/XMLSource.java b/tools/cldr-code/src/main/java/org/unicode/cldr/util/XMLSource.java index 780cbfc7317..3e84b5872d1 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/util/XMLSource.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/util/XMLSource.java @@ -1595,8 +1595,23 @@ public String getLocaleID() { }; private static final boolean SKIP_SINGLEZONES = false; + + /** + * A special source for codes used as fallback. For example, the path + * //ldml/localeDisplayNames/languages/language[@type="blo"] gets a constructed value based + * on the code "blo". + */ private static XMLSource constructedItems = new SimpleXMLSource(CODE_FALLBACK_ID); + /** + * Include special brackets in constructed values to distinguish them from regular values, + * For example, "vai" is a language code, and in some languages it is also the name of that + * language. "⟦vai⟧" is unambiguously a constructed value. + */ + private static String CONSTRUCTED_VALUE_PREFIX = "⟦"; // U+27E6 + + private static String CONSTRUCTED_VALUE_SUFFIX = "⟧"; // U+27E7 + static { StandardCodes sc = StandardCodes.make(); Map> countries_zoneSet = sc.getCountryToZoneSet(); @@ -1708,7 +1723,7 @@ public String getLocaleID() { + "[@type=\"" + keyDisplayNames[i] + "\"]", - keyDisplayNames[i]); + makeConstructedValue(keyDisplayNames[i])); } for (int i = 0; i < typeDisplayNames.length; ++i) { constructedItems.putValueAtPath( @@ -1719,7 +1734,7 @@ public String getLocaleID() { + "[@type=\"" + typeDisplayNames[i][0] + "\"]", - typeDisplayNames[i][0]); + makeConstructedValue(typeDisplayNames[i][0])); } constructedItems.freeze(); allowDuplicates = Collections.unmodifiableMap(allowDuplicates); @@ -1754,7 +1769,11 @@ private static String addFallbackCodeToConstructedItems( .insert(fullpathBuf.lastIndexOf("]") + 1, "[@alt=\"" + alt + "\"]") .toString(); } - return constructedItems.putValueAtPath(fullpath, value); + return constructedItems.putValueAtPath(fullpath, makeConstructedValue(value)); + } + + private static String makeConstructedValue(String value) { + return CONSTRUCTED_VALUE_PREFIX + value + CONSTRUCTED_VALUE_SUFFIX; } @Override