Make Ukrainian locale name follow ISO 639, update it and add tests#957
Make Ukrainian locale name follow ISO 639, update it and add tests#957nykula wants to merge 1 commit intopython-pendulum:masterfrom
Conversation
|
|
||
| def diff_for_humans(): | ||
| d = pendulum.now().subtract(seconds=1) | ||
| assert d.diff_for_humans(locale=locale) == "кілька секунд тому" |
There was a problem hiding this comment.
assert d.diff_for_humans(locale=locale) == "1 секунду тому"
There was a problem hiding this comment.
Pendulum considers diffs less than 10 seconds, including 0 or 1, to be "a few seconds", so I'd leave this test as is, which matches the behavior of other locales.
|
|
||
|
|
||
| locale = { | ||
| 'plural': lambda n: 'few' if (((0 == 0 and ((0 == 0))) and ((n % 10) == (n % 10) and (((n % 10) >= 2 and (n % 10) <= 4)))) and (not ((n % 100) == (n % 100) and (((n % 100) >= 12 and (n % 100) <= 14))))) else 'many' if ((((0 == 0 and ((0 == 0))) and ((n % 10) == (n % 10) and (((n % 10) == 0)))) or ((0 == 0 and ((0 == 0))) and ((n % 10) == (n % 10) and (((n % 10) >= 5 and (n % 10) <= 9))))) or ((0 == 0 and ((0 == 0))) and ((n % 100) == (n % 100) and (((n % 100) >= 11 and (n % 100) <= 14))))) else 'one' if (((0 == 0 and ((0 == 0))) and ((n % 10) == (n % 10) and (((n % 10) == 1)))) and (not ((n % 100) == (n % 100) and (((n % 100) == 11))))) else 'other', |
There was a problem hiding this comment.
There are an awful lot of 0 == 0 in here. More than zero is too many
There was a problem hiding this comment.
Agreed that checking zero against zero is useless. But that part comes from clock, which generates the condition from Babel data? Such generated checks are also present in cs, pl, sk locales. I'm open to trying to fix this, but can you suggest how I should approach it?
|
|
||
| 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 тижнів тому"
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?
|
|
||
| d = pendulum.now().subtract(days=2) | ||
| assert d.diff_for_humans(locale=locale) == "2 дні тому" | ||
|
|
There was a problem hiding this comment.
d = pendulum.now().subtract(days=5)
assert d.diff_for_humans(locale=locale) == "5 днів тому"
There was a problem hiding this comment.
Makes sense to check, thanks, will commit when I have more time.
Pull Request Check List
Fixes #955.