Skip to content
Draft
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,24 @@ public static boolean isFallbackValue(CLDRFile file, String path) {
status.pathWhereFound.equals(GlossonymConstructor.PSEUDO_PATH);
}

/**
* Per UTS #35 Part 4, {@code intervalFormatItem} elements do not inherit from {@code root} for
* non-root locales. Uses {@code skipInheritanceMarker = false} so that an explicit {@code ↑↑↑}
* vetted in a non-root locale is treated as sourced from that locale rather than {@code root}.
*/
public static boolean isExcludedRootInheritance(CLDRFile file, String path) {
if (!file.isResolved()
|| XMLSource.ROOT_ID.equals(file.getLocaleID())
|| !path.contains("/intervalFormatItem[")) {
return false;
}
if (!LdmlConvertRules.INTERVAL_FORMAT_ITEM_PATTERN.matcher(path).matches()) {
return false;
}
return XMLSource.ROOT_ID.equals(
file.getSourceLocaleIdExtended(path, null, false /* skipInheritanceMarker */));
}

/** Read all paths in the file, and assign each to a JSONSection. Return the map. */
private Map<JSONSection, List<CldrItem>> mapPathsToSections(
AtomicInteger readCount,
Expand Down Expand Up @@ -615,6 +633,9 @@ private Map<JSONSection, List<CldrItem>> mapPathsToSections(
if (!includeRedundant && isFallbackValue(file, path)) {
continue;
}
if (isExcludedRootInheritance(file, path)) {
continue;
}

// now get the fullpath and value
String fullPath = file.getFullXPath(path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,11 @@ public static boolean attrValueAsArraySet(final String nodeName, final String ke
*/
public static final Pattern VERSION_PATTERN = Pattern.compile("//ldml/identity/version.*");

/** Interval format items do not inherit from root for non-root locales (UTS #35 Part 4). */
public static final Pattern INTERVAL_FORMAT_ITEM_PATTERN =
Pattern.compile(
"//ldml/dates/calendars/calendar\\[@type=\"[^\"]+\"\\](?:\\[[^\\]]+\\])*/dateTimeFormats/intervalFormats(?:\\[[^\\]]+\\])*/intervalFormatItem\\[[^\\]]+\\](?:\\[[^\\]]+\\])*/greatestDifference(?:\\[[^\\]]+\\])+");

/** A simple class to hold the specification of a path transformation. */
public static class PathTransformSpec {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ private void processMainLocale(CLDRLocale l) throws Throwable {

if (xpath.endsWith("/alias")) continue;
if (Ldml2JsonConverter.isFallbackValue(f, xpath)) continue;
if (Ldml2JsonConverter.isExcludedRootInheritance(f, xpath)) continue;
final String v = f.getStringValue(xpath);

// Handle the no inheritance marker.
Expand Down
Loading
Loading