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-17514 Pages too big: divide Length into Metric and Other #3805

Merged
merged 1 commit into from
Jun 13, 2024
Merged
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 @@ -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
Loading