summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMaximilian Merz <git@mxmerz.de>2018-03-13 16:28:39 +0100
committerClaude Paroz <claude@2xlibre.net>2018-05-10 15:53:33 +0200
commit78912ccd0e1fcdfe98ca85081c9eb8acb7aa1f6d (patch)
tree19cca377b1dfa012330b96237df93dadd503a106 /tests
parent704443acacf0dfbcb1c52df4b260585055754ce7 (diff)
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.
Diffstat (limited to 'tests')
-rw-r--r--tests/humanize_tests/tests.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/humanize_tests/tests.py b/tests/humanize_tests/tests.py
index df9ae4f35d..2414a55ed7 100644
--- a/tests/humanize_tests/tests.py
+++ b/tests/humanize_tests/tests.py
@@ -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