mirror of
https://github.com/django/django.git
synced 2025-08-02 18:13:02 +00:00
Fixed #21408 — German Translation for “3 days ago”
The problem: “3 days ago” should translate to “vor 3 Tagen” in German, while “3 days” translates to “3 Tage”. #21408 describes that django always translated to “Tage”, even when the dative “Tagen” was correct. The same applies to months (“Monate”/“Monaten”) and years (“Jahre”/“Jahren”). The solution: Let `timesince` caller provide the string dict to use for the time-related strings.
This commit is contained in:
parent
704443acac
commit
78912ccd0e
6 changed files with 125 additions and 17 deletions
|
@ -289,3 +289,29 @@ class HumanizeTests(SimpleTestCase):
|
|||
self.assertEqual(expected_natural_time, natural_time)
|
||||
finally:
|
||||
humanize.datetime = orig_humanize_datetime
|
||||
|
||||
def test_dative_inflection_for_timedelta(self):
|
||||
"""Translation may differ depending on the string it is inserted in."""
|
||||
test_list = [
|
||||
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',
|
||||
]
|
||||
|
||||
orig_humanize_datetime, humanize.datetime = humanize.datetime, MockDateTime
|
||||
try:
|
||||
with translation.override('de'), self.settings(USE_L10N=True):
|
||||
self.humanize_tester(test_list, result_list, 'naturaltime')
|
||||
finally:
|
||||
humanize.datetime = orig_humanize_datetime
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue