Skip to content

Commit

Permalink
CLDR-17514 Pages too big: divide Length into Metric and Other (#3805)
Browse files Browse the repository at this point in the history
  • Loading branch information
btangmu authored Jun 13, 2024
1 parent 22afc9b commit e710b4c
Showing 1 changed file with 26 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ public enum PageId {
Measurement_Systems(SectionId.Units, "Measurement Systems"),
Duration(SectionId.Units),
Graphics(SectionId.Units),
Length(SectionId.Units),
Length_Metric(SectionId.Units, "Length Metric"),
Length_Other(SectionId.Units, "Length Other"),
Area(SectionId.Units),
Volume_Metric(SectionId.Units, "Volume Metric"),
Volume_US(SectionId.Units, "Volume US"),
Expand Down Expand Up @@ -2221,12 +2222,7 @@ private static String fix(String input, int orderIn) {
while (true) {
int functionStart = input.indexOf('&', pos);
if (functionStart < 0) {
if ("Volume".equals(input)) {
return getVolumePageId(args.value[0] /* path */).toString();
} else if ("Other Units".equals(input)) {
return getOtherUnitsPageId(args.value[0] /* path */).toString();
}
return input;
return adjustPageForPath(input, args.value[0] /* path */).toString();
}
int functionEnd = input.indexOf('(', functionStart);
int argEnd =
Expand All @@ -2246,12 +2242,35 @@ private static String fix(String input, int orderIn) {
}
}

private static String adjustPageForPath(String input, String path) {
if ("Length".equals(input)) {
return getLengthPageId(path).toString();
}
if ("Other Units".equals(input)) {
return getOtherUnitsPageId(path).toString();
}
if ("Volume".equals(input)) {
return getVolumePageId(path).toString();
}
return input;
}

private static Set<UnitConverter.UnitSystem> METRIC_UNITS =
Set.of(UnitConverter.UnitSystem.metric, UnitConverter.UnitSystem.metric_adjacent);

private static Set<UnitConverter.UnitSystem> US_UNITS =
Set.of(UnitConverter.UnitSystem.ussystem);

private static PageId getLengthPageId(String path) {
final String shortUnitId = getShortUnitId(path);
if (isSystemUnit(shortUnitId, METRIC_UNITS)) {
return PageId.Length_Metric;
} else {
// Could further subdivide into US/Other with isSystemUnit(shortUnitId, US_UNITS)
return PageId.Length_Other;
}
}

private static PageId getVolumePageId(String path) {
final String shortUnitId = getShortUnitId(path);
if (isSystemUnit(shortUnitId, METRIC_UNITS)) {
Expand Down

0 comments on commit e710b4c

Please sign in to comment.