Repository navigation
Support CLDR 49 - #1427
Support CLDR 49#1427tomasr8 wants to merge 15 commits into
Conversation
metazones can now contain aliases, which the parser currently cannot handle. This updates the import script to return an `Alias` instance for aliased metazones.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1427 +/- ##
==========================================
+ Coverage 93.57% 93.66% +0.08%
==========================================
Files 27 27
Lines 4951 4971 +20
==========================================
+ Hits 4633 4656 +23
+ Misses 318 315 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| 'M': [1, 2, 3, 4, 5], 'L': [1, 2, 3, 4, 5], # month | ||
| 'w': [1, 2], 'W': [1], # week | ||
| 'd': [1, 2], 'D': [1, 2, 3], 'F': [1], 'g': None, # day | ||
| 'd': [1, 2, 3], 'D': [1, 2, 3], 'F': [1], 'g': None, # day |
There was a problem hiding this comment.
There's a new ddd (dayOfMonth) pattern now. This is just to make the import script not bail, the ddd pattern does not do anything useful (yet)
| '1,099.98 US dollars' | ||
| >>> format_currency(1099.98, 'USD', locale='ee', format_type='name') | ||
| 'us ga dollar 1,099.98' | ||
| >>> format_currency(1099.98, 'USD', locale='my', format_type='name') |
There was a problem hiding this comment.
my is one of the few locales that still put the amount at the end
| COMMON_FILESUM = 'c704a2baf9ce4e28f40e242f8b2fbd0123579bb2c56daaaf8a92d72abd02485a1f60095c3cc4fe89eaf2d5c9f5fd07954c2eaee88839f97e18b1ff37cd62e2d8' | ||
| EXEMPLARS_FILESUM = '8c0331f4927833499d24a716e2d072a87ae169098d41886d3ae51028e4f5033f8c139339c2c8b073b59da8431663c91ed15d24a61aaa78305994e22326521836' | ||
|
|
||
| # In CLDR 49, the common zip no longer contains the locales below Basic |
There was a problem hiding this comment.
We need to decide if we want to keep the locales with low coverage or get rid of them.. This is the alternative where we keep them for now until CLDR 50 removes them.
There was a problem hiding this comment.
Yeah, let's keep them for now, I think. I'd maybe preferably like an RFC issue where the user community could chip in, but I don't think people who rely on the low-covered locales would ever find it.
There was a problem hiding this comment.
Yeah I prefer "doing nothing" (i.e. keeping all the locales as is) until CLDR decides what to do.. Perhaps if it was just a few locales it'd be fine, but with this many there's a good chance people are using some of them.
| meta_zones[mzid] = _parse_zone_names(elem, ['meta_zones', mzid]) | ||
|
|
||
|
|
||
| def _parse_zone_names(elem, ctxt): |
There was a problem hiding this comment.
metazones can now have aliases, e.g.:
<metazone type="British"><long>
<alias source="locale" path="../../metazone[@type='GMT']/long"/>
</long></metazone>|
|
||
|
|
||
| @pytest.mark.parametrize("test_case", toml_test_cases_path.glob("bad.*.toml"), ids=lambda p: p.name) | ||
| @pytest.mark.parametrize("test_case", tuple(toml_test_cases_path.glob("bad.*.toml")), ids=lambda p: p.name) |
There was a problem hiding this comment.
this is just to silence a pytest deprecation warning
| ("Europe/Kiev", {"locale": "en"}, "Eastern European Time"), | ||
| # Since CLDR 49, the `British` and `Irish` metazones alias the long names | ||
| # they don't define themselves to the `GMT` metazone (in root.xml) | ||
| ("Europe/London", {"locale": "en", "zone_variant": "generic"}, "British Time"), |
There was a problem hiding this comment.
Additional test cases for the British/Irish metazone changes
|
|
||
|
|
||
| def test_locale_count(): | ||
| assert len(localedata.locale_identifiers()) == 1147 |
There was a problem hiding this comment.
Now that some locales might be removed, a simple smoke test to keep track of the number of locales could be handy?
There was a problem hiding this comment.
Might want to add a docstring explaining what this test is for? We have the context here in the PR, but it'd be convenient for it to be in the code too.
|
cc @akx :) |
|
(not entirely sure why the Windows test failed, especially since one of the Ubuntu tests passed..) |
It was a checksum failure, restarting the job fixed it. |
akx
left a comment
There was a problem hiding this comment.
Very small comments, looks great. Thanks for doing the work!
| >>> Locale('en', 'US').time_zones['Europe/London']['long']['daylight'] | ||
| 'British Summer Time' |
There was a problem hiding this comment.
Review note to self: this is now in meta_zones -> British -> long.
| # In CLDR 49, the common zip no longer contains the locales below Basic | ||
| # coverage. See: https://cldr.unicode.org/downloads/cldr-49#migration. The | ||
| # stated plan is to remove all locales below Basic coverage in CLDR 50. Since | ||
| # presumably some locales will achieve Basic coverage in CLDR 50, we should keep | ||
| # all the existing below-Basic coverage locales as is until CLDR 50 makes it | ||
| # official. | ||
| # | ||
| # The below-Basic locales have been moved to a separate file | ||
| # ("cldr-exemplars-delta-49.zip"). This file however contains also ~1500 files | ||
| # from the CLDR repository's `exemplars/` directory. These are locales that | ||
| # don't have data in CLDR and were never available in Babel. We only want to | ||
| # merge below-Basic locales with the common data while keeping the exemplars out. | ||
| # To do so, we generate an explicit list of all the below-Basic locales. | ||
| # | ||
| # To regnerate the list, run: | ||
| # | ||
| # git clone --depth 1 --branch release-49 --filter=blob:none --no-checkout https://github.com/unicode-org/cldr | ||
| # comm -13 <(unzip -Z1 cldr-common-49.zip 'common/main/*.xml' | sort) \ | ||
| # <(git -C cldr ls-tree --name-only release-49 common/main/ | grep '\.xml$' | sort) \ | ||
| # | sed 's|common/main/||; s|\.xml$||' | ||
| # | ||
| BELOW_BASIC_LOCALES = frozenset( |
| COMMON_FILESUM = 'c704a2baf9ce4e28f40e242f8b2fbd0123579bb2c56daaaf8a92d72abd02485a1f60095c3cc4fe89eaf2d5c9f5fd07954c2eaee88839f97e18b1ff37cd62e2d8' | ||
| EXEMPLARS_FILESUM = '8c0331f4927833499d24a716e2d072a87ae169098d41886d3ae51028e4f5033f8c139339c2c8b073b59da8431663c91ed15d24a61aaa78305994e22326521836' | ||
|
|
||
| # In CLDR 49, the common zip no longer contains the locales below Basic |
There was a problem hiding this comment.
Yeah, let's keep them for now, I think. I'd maybe preferably like an RFC issue where the user community could chip in, but I don't think people who rely on the low-covered locales would ever find it.
| for child in width_elem: | ||
| if child.tag == 'alias': | ||
| info[width] = Alias(_translate_alias([*ctxt, width], child.attrib['path'])) | ||
| break | ||
| names[child.tag] = str(child.text) | ||
| else: | ||
| if names: | ||
| info[width] = names |
There was a problem hiding this comment.
The for: else: construct took me a couple of reads. Could you add a comment clarifying the else branch (which, IIUC, we take if we didn't encounter an alias for this width?)
There was a problem hiding this comment.
Sure! I'll either add a comment or if removing the for-else construct makes it simpler, I'll do that
|
|
||
|
|
||
| def test_locale_count(): | ||
| assert len(localedata.locale_identifiers()) == 1147 |
There was a problem hiding this comment.
Might want to add a docstring explaining what this test is for? We have the context here in the PR, but it'd be convenient for it to be in the code too.
|
I'm curious, do you want to make a new release before merging this? That way we get a release with CLDR 48 (the latest babel release has CLDR 47) or do we go straight to 49? |
CDLR 49 is out, let's see how much stuff broke :D https://cldr.unicode.org/downloads/cldr-49
For the record, this PR is to just make the test suite pass and patch any breaking changes. CLDR 49 is including some new data which we can make use of (e.g. #1383) but that is better left to a follow up.
The main changes here are twofold: