mirror of https://github.com/django/django.git
Refs #21408 -- Updated naturaltime translation test.
Upcoming German translations will not differ for past and future naturaltime translations. Using Czech language instead.
This commit is contained in:
parent
8ef8bc0f64
commit
ddcb9e8062
|
@ -290,28 +290,46 @@ class HumanizeTests(SimpleTestCase):
|
||||||
finally:
|
finally:
|
||||||
humanize.datetime = orig_humanize_datetime
|
humanize.datetime = orig_humanize_datetime
|
||||||
|
|
||||||
def test_dative_inflection_for_timedelta(self):
|
def test_inflection_for_timedelta(self):
|
||||||
"""Translation may differ depending on the string it is inserted in."""
|
"""
|
||||||
|
Translation of '%d day'/'%d month'/… may differ depending on the context
|
||||||
|
of the string it is inserted in.
|
||||||
|
"""
|
||||||
test_list = [
|
test_list = [
|
||||||
|
# "%(delta)s ago" translations
|
||||||
now - datetime.timedelta(days=1),
|
now - datetime.timedelta(days=1),
|
||||||
now - datetime.timedelta(days=2),
|
now - datetime.timedelta(days=2),
|
||||||
now - datetime.timedelta(days=30),
|
now - datetime.timedelta(days=30),
|
||||||
now - datetime.timedelta(days=60),
|
now - datetime.timedelta(days=60),
|
||||||
now - datetime.timedelta(days=500),
|
now - datetime.timedelta(days=500),
|
||||||
now - datetime.timedelta(days=865),
|
now - datetime.timedelta(days=865),
|
||||||
|
# "%(delta)s from now" translations
|
||||||
|
now + datetime.timedelta(days=1),
|
||||||
|
now + datetime.timedelta(days=2),
|
||||||
|
now + datetime.timedelta(days=30),
|
||||||
|
now + datetime.timedelta(days=60),
|
||||||
|
now + datetime.timedelta(days=500),
|
||||||
|
now + datetime.timedelta(days=865),
|
||||||
]
|
]
|
||||||
result_list = [
|
result_list = [
|
||||||
'vor 1\xa0Tag',
|
'před 1\xa0dnem',
|
||||||
'vor 2\xa0Tagen',
|
'před 2\xa0dny',
|
||||||
'vor 1\xa0Monat',
|
'před 1\xa0měsícem',
|
||||||
'vor 2\xa0Monaten',
|
'před 2\xa0měsíci',
|
||||||
'vor 1\xa0Jahr, 4\xa0Monaten',
|
'před 1\xa0rokem, 4\xa0měsíci',
|
||||||
'vor 2\xa0Jahren, 4\xa0Monaten',
|
'před 2\xa0lety, 4\xa0měsíci',
|
||||||
|
'za 1\xa0den',
|
||||||
|
'za 2\xa0dny',
|
||||||
|
'za 1\xa0měsíc',
|
||||||
|
'za 2\xa0měsíce',
|
||||||
|
'za 1\xa0rok, 4\xa0měsíce',
|
||||||
|
'za 2\xa0roky, 4\xa0měsíce',
|
||||||
]
|
]
|
||||||
|
|
||||||
orig_humanize_datetime, humanize.datetime = humanize.datetime, MockDateTime
|
orig_humanize_datetime, humanize.datetime = humanize.datetime, MockDateTime
|
||||||
try:
|
try:
|
||||||
with translation.override('de'), self.settings(USE_L10N=True):
|
# Choose a language with different naturaltime-past/naturaltime-future translations
|
||||||
|
with translation.override('cs'), self.settings(USE_L10N=True):
|
||||||
self.humanize_tester(test_list, result_list, 'naturaltime')
|
self.humanize_tester(test_list, result_list, 'naturaltime')
|
||||||
finally:
|
finally:
|
||||||
humanize.datetime = orig_humanize_datetime
|
humanize.datetime = orig_humanize_datetime
|
||||||
|
|
Loading…
Reference in New Issue