fix: rename Ukrainian locale code from 'ua' to 'uk' - #996
Closed
mayuriphad wants to merge 1 commit into
Closed
Conversation
'ua' is the ISO 3166 country code for Ukraine, not a language code.
The correct ISO 639 language code for Ukrainian is 'uk', which is what
locale.getlocale() and Accept-Language headers actually report (e.g.
'uk_UA'). Locale.load('uk') previously raised ValueError.
Rename the locales/ua package to locales/uk and add an alias table in
Locale.load() so the old 'ua' code keeps resolving to the same
translations for backwards compatibility.
Fixes python-pendulum#955
Collaborator
|
Duplicate of #957 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
uais an ISO 3166 country code (Ukraine), not the ISO 639 language code for Ukrainian, which isuk. This mismatch means:pendulum.now().diff_for_humans(locale='uk')raisesValueError: Locale [uk] does not exist., even thoughukis whatlocale.getlocale()andAccept-LanguageHTTP headers actually report (e.g.uk_UA,uk-UA).locale='ua'code worked.Fix
src/pendulum/locales/uatosrc/pendulum/locales/uk(module docstrings/imports updated accordingly).Locale.load()insrc/pendulum/locales/locale.pyso the olduacode still resolves to the same Ukrainian translations, preserving backwards compatibility for existing callers.Test plan
tests/localization/test_uk.py:test_diff_for_humansexercisesdiff_for_humans(locale='uk').test_ua_is_an_alias_for_ukassertsLocale.load('ua')andLocale.load('uk')produce identical translations, and thatdiff_for_humans(locale='ua')anddiff_for_humans(locale='uk')match.master(ModuleNotFoundError: No module named 'pendulum.locales.uk.locale') and passes after the fix.tests/localization/locally; failures there are pre-existing and unrelated (they require the compiledtestextra forpendulum.travel_to, which couldn't be built in this environment due to an unrelated Rust/MSVC linker issue).Fixes #955