diff --git a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/Dashboard.java b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/Dashboard.java index 5385b4403e4..e4e99292322 100644 --- a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/Dashboard.java +++ b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/Dashboard.java @@ -141,7 +141,7 @@ public static final class ReviewNotificationGroup { @Schema(description = "SurveyTool section", example = "Units") public String section; - @Schema(description = "SurveyTool page", example = "Volume") + @Schema(description = "SurveyTool page", example = "Area") public String page; @Schema(description = "SurveyTool header", example = "dessert-spoon-imperial") diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/util/PathHeader.java b/tools/cldr-code/src/main/java/org/unicode/cldr/util/PathHeader.java index f3519968dc9..6f067d08952 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/util/PathHeader.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/util/PathHeader.java @@ -231,10 +231,8 @@ public enum PageId { Graphics(SectionId.Units), Length(SectionId.Units), Area(SectionId.Units), - Volume(SectionId.Units), - // TODO: enable splitting Volume into Volume/Volume2 - // Reference: https://unicode-org.atlassian.net/browse/CLDR-11155 - // Volume2(SectionId.Units), + Volume_Metric(SectionId.Units, "Volume Metric"), + Volume_Other(SectionId.Units, "Volume Other"), SpeedAcceleration(SectionId.Units, "Speed and Acceleration"), MassWeight(SectionId.Units, "Mass and Weight"), EnergyPower(SectionId.Units, "Energy and Power"), @@ -721,20 +719,7 @@ public PathHeader fromPath(final String path, List failures) { samples.put(data, cleanPath); } try { - PathHeader result = - new PathHeader( - SectionId.forString(fix(data.section, 0)), - PageId.forString(fix(data.page, 0)), - fix(data.header, data.headerOrder), - (int) order, // only valid after call to fix. TODO, make - // this cleaner - fix( - data.code + (alt == null ? "" : ("-" + alt)), - data.codeOrder), - order, // only valid after call to fix - suborder, - data.status, - path); + PathHeader result = makePathHeader(data, path, alt); synchronized (cache) { PathHeader old = cache.get(path); if (old == null) { @@ -766,6 +751,56 @@ public PathHeader fromPath(final String path, List failures) { } } + private PathHeader makePathHeader(RawData data, String path, String alt) { + // Caution: each call to PathHeader.Factory.fix changes the value of + // PathHeader.Factory.order + SectionId newSectionId = SectionId.forString(fix(data.section, 0)); + String pageIdName = fix(data.page, 0); + PageId newPageId; + if ("Volume".equals(pageIdName)) { + newPageId = getVolumePageId(path); + } else { + newPageId = PageId.forString(pageIdName); + } + String newHeader = fix(data.header, data.headerOrder); + int newHeaderOrder = (int) order; + String codeDashAlt = data.code + (alt == null ? "" : ("-" + alt)); + String newCode = fix(codeDashAlt, data.codeOrder); + long newCodeOrder = order; + return new PathHeader( + newSectionId, + newPageId, + newHeader, + newHeaderOrder, + newCode, + newCodeOrder, + suborder, + data.status, + path); + } + + private static Set METRIC = + Set.of(UnitConverter.UnitSystem.metric, UnitConverter.UnitSystem.metric_adjacent); + + private PageId getVolumePageId(String path) { + // Extract the unit from the path. For example, if path is + // //ldml/units/unitLength[@type="narrow"]/unit[@type="volume-cubic-kilometer"]/displayName + // then extract "volume-cubic-kilometer" which is the long unit id + final String longUnitId = + XPathParts.getFrozenInstance(path).findAttributeValue("unit", "type"); + if (longUnitId == null) { + throw new RuntimeException("Missing unit in path " + path); + } + final UnitConverter uc = supplementalDataInfo.getUnitConverter(); + // Convert, for example, "volume-cubic-kilometer" to "cubic-kilometer" + final String shortUnitId = uc.getShortId(longUnitId); + if (!Collections.disjoint(METRIC, uc.getSystemsEnum(shortUnitId))) { + return PageId.Volume_Metric; + } else { + return PageId.Volume_Other; + } + } + private static class SectionPage implements Comparable { private final SectionId sectionId; private final PageId pageId; @@ -2476,8 +2511,6 @@ private static PageId getCharacterPageId(String cp) { if (pageId == null) { throw new InternalCldrException("Failure getting character page id"); } - // TODO: enable splitting Volume into Volume/Volume2, starting Volume2 at "acre-foot" - // Reference: https://unicode-org.atlassian.net/browse/CLDR-11155 return pageId; }