Skip to content

Commit

Permalink
CLDR-11155 Pages too big: further divisions for Volume, Units
Browse files Browse the repository at this point in the history
-Divide Volume Other into Volume US and VolumeOther

-Divide Other Units into Other Units Metric, Other Units Metric Per, Other Units US and Other Units

-New subroutines getOtherUnitsPageId, isSystemUnit, getShortUnitId

-Fix deprecation warnings: remove getSectionsToPages; fix TestZ and filterCldr
  • Loading branch information
btangmu committed Apr 5, 2024
1 parent cd4ca7b commit b750aa8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
Expand Down Expand Up @@ -241,10 +240,10 @@ public enum PageId {
Weather(SectionId.Units),
Digital(SectionId.Units),
Coordinates(SectionId.Units),
OtherUnits(SectionId.Units, "Other Units"),
OtherUnitsPer(SectionId.Units, "Other Units Per"),
OtherUnitsMetric(SectionId.Units, "Other Unitsj Metric"),
OtherUnitsMetricPer(SectionId.Units, "Other Units Metric Per"),
OtherUnitsUS(SectionId.Units, "Other Units US"),
OtherUnitsMisc(SectionId.Units, "Other Units Misc"),
OtherUnits(SectionId.Units, "Other Units"),
CompoundUnits(SectionId.Units, "Compound Units"),

Displaying_Lists(SectionId.Misc, "Displaying Lists"),
Expand Down Expand Up @@ -864,28 +863,7 @@ public static Relation<SectionId, PageId> getSectionIdsToPageIds() {
return SectionIdToPageIds;
}

/**
* Return the names for Sections and Pages that are defined, for display in menus. Both are
* ordered.
*
* @deprecated Use getSectionIdsToPageIds
*/
@Deprecated
public static LinkedHashMap<String, Set<String>> getSectionsToPages() {
LinkedHashMap<String, Set<String>> sectionsToPages = new LinkedHashMap<>();
for (PageId pageId : PageId.values()) {
String sectionId2 = pageId.getSectionId().toString();
Set<String> pages =
sectionsToPages.computeIfAbsent(sectionId2, k -> new LinkedHashSet<>());
pages.add(pageId.toString());
}
return sectionsToPages;
}

/**
* @deprecated, use the filterCldr with the section/page ids.
*/
public Iterable<String> filterCldr(String section, String page, CLDRFile file) {
public Iterable<String> filterCldr(SectionId section, PageId page, CLDRFile file) {
return new FilteredIterable(section, page, file);
}

Expand Down Expand Up @@ -2286,11 +2264,13 @@ private static PageId getVolumePageId(String path) {
private static PageId getOtherUnitsPageId(String path) {
String shortUnitId = getShortUnitId(path);
if (isSystemUnit(shortUnitId, METRIC_UNITS)) {
return shortUnitId.contains("per") ? PageId.OtherUnitsPer : PageId.OtherUnits;
return shortUnitId.contains("per")
? PageId.OtherUnitsMetricPer
: PageId.OtherUnitsMetric;
} else {
return isSystemUnit(shortUnitId, US_UNITS)
? PageId.OtherUnitsUS
: PageId.OtherUnitsMisc;
: PageId.OtherUnits;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1090,12 +1090,11 @@ public void TestZ() {
for (String item : threeLevel) {
logln(item);
}
LinkedHashMap<String, Set<String>> sectionsToPages =
org.unicode.cldr.util.PathHeader.Factory.getSectionsToPages();
logln("\nMenus:\t" + sectionsToPages.size());
for (Entry<String, Set<String>> item : sectionsToPages.entrySet()) {
final String section = item.getKey();
for (String page : item.getValue()) {
Relation<SectionId, PageId> s2p = PathHeader.Factory.getSectionIdsToPageIds();
logln("\nMenus:\t" + s2p.size());
for (Entry<SectionId, Set<PageId>> sectionAndPages : s2p.keyValuesSet()) {
final SectionId section = sectionAndPages.getKey();
for (PageId page : sectionAndPages.getValue()) {
logln("\t" + section + "\t" + page);
int count = 0;
for (String path : pathHeaderFactory.filterCldr(section, page, english)) {
Expand Down

0 comments on commit b750aa8

Please sign in to comment.