-
Notifications
You must be signed in to change notification settings - Fork 387
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 Handle CURRENCY/CURRENCY_SYMBOL paths like LANGUAGE/SCRIPT/… #4352
base: main
Are you sure you want to change the base?
Conversation
…/... -Use ExtraPaths instead of XMLSource.ResolvingSource.constructedItems -Paths constructed in this way no longer have fallback values -In ICUServiceBuilder, if currency value not found in CLDRFile, use code fallback -In TestExampleGenerator Test4528, if currency value not found in CLDRFile, use code fallback -In GenerateLocaleIDTestData, add comment to generated file indicating it was generated
Test failures in TestPathHeadersAndValues. BTW, tests passed for me locally because I didn't have The failures seem very similar to what happened for VARIANT paths in the previous PR. There, the solution was to delete INHERITANCE_MARKER from no.xml, since there was no root or code-fallback value to inherit.
hi.xml (not hi_Latn.xml) has
https://st.unicode.org/cldr-apps/v#/hi_Latn/C_SAmerica/4ae7a40dd1e39d05 inherits from same path in root, but it's not really root, it's code fallback https://st.unicode.org/cldr-apps/v#/hi/C_SAmerica/4ae7a40dd1e39d05 ditto https://st.unicode.org/cldr-apps/v#/root/C_SAmerica/4ae7a40dd1e39d05 This brings us back to https://unicode-org.atlassian.net/browse/CLDR-18294 which maybe blocks this PR |
You might as well fix those paths with this ticket, and then the tests would pass. (Assuming that it lists all the problem cases, and you do with -e10. It isn't blocked by https://unicode-org.atlassian.net/browse/CLDR-18294. If anything, the reverse. Because for that to land, you would have to fix those paths by hand anyway. |
@macchiati I've tried removing ↑↑↑ from the paths that trigger errors. The paths occur, with ↑↑↑, in locales "hi" and "no", while the errors implicate "hi_Latin" and "nn" (which sometimes inherit from "hi" and "no", respectively). The errors still occur. I'm investigating. One strange thing is here:
The The inheritance involved in the errors seems to be from code-fallback, even though with the changes in this PR there are no longer any code-fallback values to inherit for currency paths, in the old way. This long function in XMLSource.java plays a major role:
At the end, it sort of defaults to CODE_FALLBACK_ID, for lack of any better result, seemingly regardless of whether or not any code value was found to fall back on. |
Another thing I noticed is that some currency paths were already implemented as "extra" paths before this PR. This code in ExtraPaths.java (formerly in CLDRFile.java) adds them on a per-locale basis, since
This overlaps with the "constant" (non-locale-specific) code that adds currency paths like this:
-- based on what was formerly (before this PR) done in XMLSource.java with fallback code values. I think this means that some paths are added twice, but that should be harmless (except maybe for performance) -- they're added to sets, not to arrays, so the duplication has no effect. I don't know how the two code sets |
I've added some debugging code to this PR, including removal of some ↑↑↑ paths in locales "hi" and "no" although that didn't solve the test failures |
I put together a draft doc to explain the overall picture, to make sure we are all on the same page. (The goal is to create a page in https://cldr.unicode.org/development from this source (using Copy from Markdown), once the content settles down a bit.) https://docs.google.com/document/d/1RWRGMhIYA5TOuJ1b0xvnWKUMoof0Rjyp_xGJWRs8ruw |
-Use getGoodAvailableCodes instead of getBcp47Keys().getAll(cu) for consistency and efficiency and to obviate toUpperCase
@macchiati thanks for that helpful document! It sheds a lot of light on this ticket and also https://unicode-org.atlassian.net/browse/CLDR-18217 Meanwhile I made another commit, removing some redundant addition of constant currency paths, and, having determined that the two sets supplementalData.getBcp47Keys().getAll("cu") and sc.getGoodAvailableCodes are identical aside from that latter being uppercase (size 307 BTW), calling only the latter for consistency. |
for (String code : supplementalData.getBcp47Keys().getAll("cu")) { | ||
String currencyCode = code.toUpperCase(); | ||
toAddTo.add( | ||
"//ldml/numbers/currencies/currency[@type=\"" + currencyCode + "\"]/symbol"); |
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.
This was redundant, given addPaths(NameType.CURRENCY_SYMBOL)
toAddTo.add( | ||
"//ldml/numbers/currencies/currency[@type=\"" | ||
+ currencyCode | ||
+ "\"]/displayName"); |
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.
This was redundant, given addPaths(NameType.CURRENCY)
// This code is locale-dependent due to pluralCounts. Compare addPaths(NameType.CURRENCY) | ||
// and addPaths(NameType.CURRENCY_SYMBOL) above, which are locale-independent. | ||
if (!pluralCounts.isEmpty()) { | ||
for (String code : StandardCodes.make().getGoodAvailableCodes(currency)) { |
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.
getGoodAvailableCodes
returns the same set of 307 codes as supplementalData.getBcp47Keys().getAll("cu")
aside from being already uppercase
-Remove some paths from xml with inheritance marker but nothing to inherit, failing TestPathHeadersAndValues -Remove debugging code added earlier in this PR
With the 4th commit, tests pass locally! For the hi_Latn failures, it turned out that inheritance was from en_IN, so that's where some paths needed deleting. For the nn failures, it was necessary to remove a larger number of paths from no.xml -- all currency symbol paths with inheritance marker. |
-Both paths have alt=narrow values -Console check fails if path with alt is present but the corresponding path without alt is missing
A 5th commit was need to fix console check error "path with alt is present but the corresponding path without alt is missing". Hard-code BYN and RON as currency symbols in no.xml. |
Hmmm. For the currency codes, we shouldn't remove the ^^^; those are all likely to be real inheritance from the code. That is, it is unlikely for a language to use "en" as the name of English, but not at all unlikely for it to use USD for the US currency. So rather than delete the ^^^, I think they need to be replaced by the code (for top-level locales). So what you did for BYN and RON. |
@macchiati Given that the currency codes are often suitable as values, is there anything wrong with the original fallback mechanism for currency paths? Maybe this PR isn't needed. What are the relative advantages of keeping code fallback, with ↑↑↑ to inherit, versus using extra paths and hard-coding the values in some top-level locales (like "no")? It might be easier or more economical just to keep code fallback. There are also other
Which (if any) of these should stay the way they are, with code fallback, and which (if any) should be changed to use the extra-path mechanism? |
Good question. I think the ^^^ to CODE_FALLBACK for currency codes is still a problem, because of implementations that don't do the spec'd behavior (map to the code). One approach we could take is to add those to ROOT. But adding more conformance tests could fix that. We should probably discuss more in Tuesday's meeting. I think all the investigation has still been worth it (no matter what we doe), because it has exposed issues that have been hidden. |
I'm converting this PR to "draft", since we've (at least tentatively) concluded that the code-fallback values should be kept for currency paths. For example, the code/value "USD" for "US Dollars" is commonly used and does not trigger an error or warning. We might still want to reference this draft PR as it relates to work in progress. I've made a separate PR #4368 copying the unproblematic changes from this PR. |
-Use ExtraPaths instead of XMLSource.ResolvingSource.constructedItems
-Paths constructed in this way no longer have fallback values
-In ICUServiceBuilder, if currency value not found in CLDRFile, use code fallback
-In TestExampleGenerator Test4528, if currency value not found in CLDRFile, use code fallback
-In GenerateLocaleIDTestData, add comment to generated file indicating it was generated
CLDR-17014
ALLOW_MANY_COMMITS=true