-
Notifications
You must be signed in to change notification settings - Fork 386
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-17014 No code fallbacks for language paths #4254
base: main
Are you sure you want to change the base?
Changes from all commits
f846a3c
7efc8d8
cdb5251
aaf5e63
e3f2f32
518b994
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package org.unicode.cldr.util; | ||
|
||
import java.util.Collection; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
import java.util.TreeSet; | ||
|
||
public class ExtraPaths { | ||
|
||
private static final Collection<String> languagePaths = new HashSet<>(); | ||
|
||
static void appendLanguages(Collection<String> toAddTo) { | ||
if (languagePaths.isEmpty()) { | ||
populateLanguagePaths(); | ||
} | ||
toAddTo.addAll(languagePaths); | ||
} | ||
|
||
private static void populateLanguagePaths() { | ||
Set<String> codes = new TreeSet<>(); | ||
StandardCodes sc = StandardCodes.make(); | ||
codes.addAll(sc.getGoodAvailableCodes(StandardCodes.CodeType.language)); | ||
codes.remove(LocaleNames.ROOT); | ||
codes.addAll( | ||
List.of( | ||
"ar_001", "de_AT", "de_CH", "en_AU", "en_CA", "en_GB", "en_US", "es_419", | ||
"es_ES", "es_MX", "fa_AF", "fr_CA", "fr_CH", "frc", "hi_Latn", "lou", | ||
"nds_NL", "nl_BE", "pt_BR", "pt_PT", "ro_MD", "sw_CD", "zh_Hans", | ||
"zh_Hant")); | ||
for (String code : codes) { | ||
languagePaths.add(NameType.LANGUAGE.getKeyPath(code)); | ||
} | ||
languagePaths.add(languageAltPath("en_GB", "short")); | ||
languagePaths.add(languageAltPath("en_US", "short")); | ||
languagePaths.add(languageAltPath("az", "short")); | ||
languagePaths.add(languageAltPath("ckb", "menu")); | ||
languagePaths.add(languageAltPath("ckb", "variant")); | ||
languagePaths.add(languageAltPath("hi_Latn", "variant")); | ||
languagePaths.add(languageAltPath("yue", "menu")); | ||
languagePaths.add(languageAltPath("zh", "menu")); | ||
languagePaths.add(languageAltPath("zh_Hans", "long")); | ||
languagePaths.add(languageAltPath("zh_Hant", "long")); | ||
} | ||
|
||
private static String languageAltPath(String code, String alt) { | ||
String fullpath = NameType.LANGUAGE.getKeyPath(code); | ||
// Insert the @alt= string after the last occurrence of "]" | ||
StringBuilder fullpathBuf = new StringBuilder(fullpath); | ||
return fullpathBuf | ||
.insert(fullpathBuf.lastIndexOf("]") + 1, "[@alt=\"" + alt + "\"]") | ||
.toString(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -190,6 +190,8 @@ | |
path.contains("/metazone") | ||
|| path.contains("/timeZoneNames") | ||
|| path.contains("/gender") | ||
|| path.startsWith( | ||
"//ldml/localeDisplayNames/languages/language") | ||
|| path.startsWith("//ldml/numbers/currencies/currency") | ||
|| path.startsWith("//ldml/personNames/sampleName") | ||
|| path.contains("/availableFormats") | ||
|
@@ -914,7 +916,7 @@ | |
} | ||
String value = swissHighGerman.getStringValue(xpath); | ||
if (value != null && value.indexOf('ß') >= 0) { | ||
warnln("«" + value + "» contains ß at " + xpath); | ||
Check warning on line 919 in tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestCLDRFile.java GitHub Actions / build
Check warning on line 919 in tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestCLDRFile.java GitHub Actions / build
Check warning on line 919 in tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestCLDRFile.java GitHub Actions / build
Check warning on line 919 in tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestCLDRFile.java GitHub Actions / build
Check warning on line 919 in tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestCLDRFile.java GitHub Actions / build
|
||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
without fullIterable, the loop skipped the extra paths
this may be a concern in general: how often do we loop through a CLDRFile the simple way, which skips extra paths, and what are the consequences and rationale for that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point.
I think in most cases we want to iterate through the extra paths. So we might want make the iteration choice explicit, so that we can check to make sure. Maybe refactor (in separate ticket/PR) as follows.
Then we can search for the withoutExtras() calls and make sure that they are right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TestVettingDataDriven failure may be related to this. Part of that test involves writing the CLDRFile to a temporary XML file and then reading it back to verify the newly voted-on value, and that's where it's failing. It looks like the language paths, which are now extra paths, don't get written to the file. To test that, I'm starting a new branch from main that will just have a few lines added to TestSTFactory.xml...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #4256
If the same failure happens there that I see locally, it seems to indicate a long-existing bug where CldrXmlWriter doesn't write extra paths