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:
Claude Paroz 2018-09-29 15:06:11 +02:00 committed by Carlton Gibson
parent 8ef8bc0f64
commit ddcb9e8062
1 changed files with 27 additions and 9 deletions

View File

@ -290,28 +290,46 @@ class HumanizeTests(SimpleTestCase):
finally:
humanize.datetime = orig_humanize_datetime
def test_dative_inflection_for_timedelta(self):
"""Translation may differ depending on the string it is inserted in."""
def test_inflection_for_timedelta(self):
"""
Translation of '%d day'/'%d month'/ may differ depending on the context
of the string it is inserted in.
"""
test_list = [
# "%(delta)s ago" 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),
# "%(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 = [
'vor 1\xa0Tag',
'vor 2\xa0Tagen',
'vor 1\xa0Monat',
'vor 2\xa0Monaten',
'vor 1\xa0Jahr, 4\xa0Monaten',
'vor 2\xa0Jahren, 4\xa0Monaten',
'před 1\xa0dnem',
'před 2\xa0dny',
'před 1\xa0měsícem',
'před 2\xa0měsíci',
'před 1\xa0rokem, 4\xa0měsíci',
'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
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')
finally:
humanize.datetime = orig_humanize_datetime