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-13935 Add ST examples for minimumGroupingDigits #3731

Merged
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 @@ -482,6 +482,8 @@ private String constructExampleHtml(String xpath, String value, boolean nonTrivi
result = handleDecimalFormat(parts, value, showContexts);
}
}
} else if (parts.contains("minimumGroupingDigits")) {
result = handleMinimumGrouping(parts, value);
} else if (parts.getElement(2).contains("symbols")) {
result = handleNumberSymbol(parts, value);
} else if (parts.contains("defaultNumberingSystem")
Expand Down Expand Up @@ -2145,6 +2147,26 @@ public String countAttribute(Count count) {
return "[@count=\"" + count + "\"]";
}

private String handleMinimumGrouping(XPathParts parts, String value) {
String numberSystem = cldrFile.getWinningValue("//ldml/numbers/defaultNumberingSystem");
String checkPath =
"//ldml/numbers/decimalFormats[@numberSystem=\""
+ numberSystem
+ "\"]/decimalFormatLength/decimalFormat[@type=\"standard\"]/pattern[@type=\"standard\"]";
String decimalFormat = cldrFile.getWinningValue(checkPath);
DecimalFormat numberFormat = icuServiceBuilder.getNumberFormat(decimalFormat, numberSystem);
numberFormat.setMinimumGroupingDigits(Integer.parseInt(value));

double sampleNum1 = 543.21;
double sampleNum2 = 6543.21;
double sampleNum3 = 76543.21;
String example = "";
example = addExampleResult(formatNumber(numberFormat, sampleNum1), example);
example = addExampleResult(formatNumber(numberFormat, sampleNum2), example);
example = addExampleResult(formatNumber(numberFormat, sampleNum3), example);
return example;
}

private String handleNumberSymbol(XPathParts parts, String value) {
String symbolType = parts.getElement(-1);
String numberSystem = parts.getAttributeValue(2, "numberSystem"); // null if not present
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,21 @@ public void TestDateTimeComboFormats() {
"//ldml/dates/calendars/calendar[@type=\"gregorian\"]/dateTimeFormats/dateTimeFormatLength[@type=\"long\"]/dateTimeFormat[@type=\"atTime\"]/pattern[@type=\"standard\"]");
}

public void TestMinimumGroupingExamples() {
ExampleGenerator exampleGeneratorEn = getExampleGenerator("en"); // min grouping 1
ExampleGenerator exampleGeneratorEs = getExampleGenerator("es"); // min grouping 2
checkValue(
"MinimumGrouping en: 1",
"〖❬543.21❭〗〖❬6,543❭.❬21❭〗〖❬76,543❭.❬21❭〗",
exampleGeneratorEn,
"//ldml/numbers/minimumGroupingDigits");
checkValue(
"MinimumGrouping es: 2",
"〖❬543,21❭〗〖❬6543,21❭〗〖❬76.543❭,❬21❭〗",
exampleGeneratorEs,
"//ldml/numbers/minimumGroupingDigits");
}

public void TestSymbols() {
CLDRFile english = info.getEnglish();
ExampleGenerator exampleGenerator = new ExampleGenerator(english, english);
Expand Down
Loading