Make Ukrainian locale name follow ISO 639, update it and add tests#957
Open
nykula wants to merge 2 commits intopython-pendulum:masterfrom
Open
Make Ukrainian locale name follow ISO 639, update it and add tests#957nykula wants to merge 2 commits intopython-pendulum:masterfrom
nykula wants to merge 2 commits intopython-pendulum:masterfrom
Conversation
afastronomer
reviewed
Apr 8, 2026
ashb
requested changes
Apr 8, 2026
afastronomer
reviewed
Apr 8, 2026
|
|
||
| d = pendulum.now().subtract(weeks=2) | ||
| assert d.diff_for_humans(locale=locale) == "2 тижні тому" | ||
|
|
There was a problem hiding this comment.
d = pendulum.now().subtract(weeks=5)
assert d.diff_for_humans(locale=locale) == "5 тижнів тому"
Author
There was a problem hiding this comment.
weeks=5 behaves in the same way as months=1, resulting in 1 місяць тому. Should I add that assertion?
Author
There was a problem hiding this comment.
All locales behave the same in this regard. @afastronomer most likely meant that from the grammar point of view, 2 weeks and 5 weeks correspond to different forms in Ukrainian. But the latter form is currently unused in Pendulum; there's no feature, that I know of, to get a human representation of a duration in a specific unit such as weeks. One way to get to the form is:
pendulum.locale('uk').translation(f"units.week.{pendulum.locale('uk').plural(5)}").format(5)
# -> '5 тижнів'
afastronomer
reviewed
Apr 8, 2026
Secrus
reviewed
Apr 10, 2026
Comment on lines
+56
to
+60
| lower = locale.lower() | ||
| if lower == 'ua': | ||
| # Backward compatibility. Ukrainian was 'ua' initially. | ||
| lower = 'uk' | ||
| return lower |
Collaborator
There was a problem hiding this comment.
Don't think we need that, since the initial locale had the wrong code. @ashb what do you think?
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.
Pull Request Check List
Fixes #955.