Skip to content

Commit

Permalink
CLDR-17014 Avoid adding constant currency paths twice; getGoodAvailab…
Browse files Browse the repository at this point in the history
…leCodes; messages (#4368)
  • Loading branch information
btangmu authored Feb 14, 2025
1 parent 0899783 commit 9e98132
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
1 change: 1 addition & 0 deletions common/testData/localeIdentifiers/localeDisplayName.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# DO NOT EDIT THIS FILE, instead regenerate it using GenerateLocaleIDTestData.java
# Test data for locale display name generation
# Copyright © 1991-2025 Unicode, Inc.
# For terms of use, see http://www.unicode.org/copyright.html
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,18 @@ public class GenerateLocaleIDTestData {
private static final CLDRConfig CLDR_CONFIG = CLDRConfig.getInstance();
private static final CLDRFile ENGLISH = CLDR_CONFIG.getEnglish();

private static final String DO_NOT_EDIT =
"# DO NOT EDIT THIS FILE, instead regenerate it using "
+ GenerateLocaleIDTestData.class.getSimpleName()
+ ".java";

public static void main(String[] args) throws IOException {
// localeCanonicalization.txt

try (TempPrintWriter pw =
TempPrintWriter.openUTF8Writer(
CLDRPaths.TEST_DATA + "localeIdentifiers", "localeCanonicalization.txt")) {
pw.println(DO_NOT_EDIT);
pw.println("# Test data for locale identifier canonicalization");
pw.println(CldrUtility.getCopyrightString("# "));
pw.println(
Expand Down Expand Up @@ -100,10 +106,10 @@ public static void main(String[] args) throws IOException {
"en-MM",
"zh-Hans-fonipa"
};

try (TempPrintWriter pw =
TempPrintWriter.openUTF8Writer(
CLDRPaths.TEST_DATA + "localeIdentifiers", "localeDisplayName.txt")) {
pw.println(DO_NOT_EDIT);
pw.println(
"# Test data for locale display name generation\n"
+ CldrUtility.getCopyrightString("# ")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.unicode.cldr.util;

import static org.unicode.cldr.util.StandardCodes.CodeType.currency;

import com.google.common.collect.ImmutableSet;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -276,19 +278,14 @@ private static void addDayPlurals(Set<String> toAddTo, String localeID) {

private static void addCurrencies(
Set<String> toAddTo, Set<SupplementalDataInfo.PluralInfo.Count> pluralCounts) {
for (String code : supplementalData.getBcp47Keys().getAll("cu")) {
String currencyCode = code.toUpperCase();
toAddTo.add(
"//ldml/numbers/currencies/currency[@type=\"" + currencyCode + "\"]/symbol");
toAddTo.add(
"//ldml/numbers/currencies/currency[@type=\""
+ currencyCode
+ "\"]/displayName");
if (!pluralCounts.isEmpty()) {
// This code is locale-dependent due to pluralCounts.
// Locale-independent currency paths are added elsewhere.
if (!pluralCounts.isEmpty()) {
for (String code : StandardCodes.make().getGoodAvailableCodes(currency)) {
for (SupplementalDataInfo.PluralInfo.Count count : pluralCounts) {
toAddTo.add(
"//ldml/numbers/currencies/currency[@type=\""
+ currencyCode
+ code
+ "\"]/displayName[@count=\""
+ count.toString()
+ "\"]");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ private void checkFullpathValue(
+ locale
+ ",\t Value=null, \tPath: "
+ path
+ ",\t Source: "
+ source
+ ",\t IsExtraPath: "
+ isExtraPath);
}
Expand Down

0 comments on commit 9e98132

Please sign in to comment.