Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLDR-17014 Use special brackets to distinguish fallback values based on codes #3919

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions tools/cldr-code/src/main/java/org/unicode/cldr/util/XMLSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Set<String>> countries_zoneSet = sc.getCountryToZoneSet();
Expand Down Expand Up @@ -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(
Expand All @@ -1719,7 +1734,7 @@ public String getLocaleID() {
+ "[@type=\""
+ typeDisplayNames[i][0]
+ "\"]",
typeDisplayNames[i][0]);
makeConstructedValue(typeDisplayNames[i][0]));
}
constructedItems.freeze();
allowDuplicates = Collections.unmodifiableMap(allowDuplicates);
Expand Down Expand Up @@ -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
Expand Down
Loading