Skip to content

fix: rename Ukrainian locale code from 'ua' to 'uk' - #996

Closed
mayuriphad wants to merge 1 commit into
python-pendulum:masterfrom
mayuriphad:fix/ukrainian-locale-code
Closed

fix: rename Ukrainian locale code from 'ua' to 'uk'#996
mayuriphad wants to merge 1 commit into
python-pendulum:masterfrom
mayuriphad:fix/ukrainian-locale-code

Conversation

@mayuriphad

Copy link
Copy Markdown

Summary

ua is an ISO 3166 country code (Ukraine), not the ISO 639 language code for Ukrainian, which is uk. This mismatch means:

  • pendulum.now().diff_for_humans(locale='uk') raises ValueError: Locale [uk] does not exist., even though uk is what locale.getlocale() and Accept-Language HTTP headers actually report (e.g. uk_UA, uk-UA).
  • Only the non-standard locale='ua' code worked.

Fix

  • Renamed src/pendulum/locales/ua to src/pendulum/locales/uk (module docstrings/imports updated accordingly).
  • Added an alias table to Locale.load() in src/pendulum/locales/locale.py so the old ua code still resolves to the same Ukrainian translations, preserving backwards compatibility for existing callers.

Test plan

  • Added tests/localization/test_uk.py:
    • test_diff_for_humans exercises diff_for_humans(locale='uk').
    • test_ua_is_an_alias_for_uk asserts Locale.load('ua') and Locale.load('uk') produce identical translations, and that diff_for_humans(locale='ua') and diff_for_humans(locale='uk') match.
  • Verified the new test fails on master (ModuleNotFoundError: No module named 'pendulum.locales.uk.locale') and passes after the fix.
  • Ran tests/localization/ locally; failures there are pre-existing and unrelated (they require the compiled test extra for pendulum.travel_to, which couldn't be built in this environment due to an unrelated Rust/MSVC linker issue).

Fixes #955

'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
Copilot AI lite review requested due to automatic review settings August 20, 2026 12:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Secrus

Secrus commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

Duplicate of #957

@Secrus Secrus marked this as a duplicate of #957 Aug 20, 2026
@Secrus Secrus closed this Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ukrainian locale should be uk not ua

3 participants