summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBouke Haarsma <bouke@webatoom.nl>2013-11-05 10:54:23 +0100
committerBaptiste Mispelon <bmispelon@gmail.com>2013-11-05 19:26:58 +0100
commite5e044da87800feb6ef63fef1765d8c05022d926 (patch)
tree90b25f2aa84598ccbf82eb49dcbcf9f919630568 /tests
parent76da053641e52db540801e18b362497c01e9bb1d (diff)
Fixed #18419 -- Full backwards compatibility for old language codes
Improved documentation about zh-* deprecation and upgrade path. Thanks to Baptiste Mispelon for the code reviews.
Diffstat (limited to 'tests')
-rw-r--r--tests/i18n/tests.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/i18n/tests.py b/tests/i18n/tests.py
index f68a7361f6..42e743dedf 100644
--- a/tests/i18n/tests.py
+++ b/tests/i18n/tests.py
@@ -893,9 +893,36 @@ class MiscTests(TransRealMixin, TestCase):
r.COOKIES = {}
r.META = {'HTTP_ACCEPT_LANGUAGE': 'zh-cn,en'}
self.assertEqual(g(r), 'zh-hans')
+
r.META = {'HTTP_ACCEPT_LANGUAGE': 'zh-tw,en'}
self.assertEqual(g(r), 'zh-hant')
+ @override_settings(
+ LANGUAGES=(
+ ('en', 'English'),
+ ('zh-cn', 'Simplified Chinese'),
+ ('zh-hans', 'Simplified Chinese'),
+ ('zh-hant', 'Traditional Chinese'),
+ ('zh-tw', 'Traditional Chinese'),
+ )
+ )
+ def test_backwards_compatibility(self):
+ """
+ While the old chinese language codes are being deprecated, they should
+ still work as before the new language codes were introduced.
+
+ refs #18419 -- this is explicitly for backwards compatibility and
+ should be removed in Django 1.9
+ """
+ g = get_language_from_request
+ r = self.rf.get('/')
+ r.COOKIES = {}
+ r.META = {'HTTP_ACCEPT_LANGUAGE': 'zh-cn,en'}
+ self.assertEqual(g(r), 'zh-cn')
+
+ r.META = {'HTTP_ACCEPT_LANGUAGE': 'zh-tw,en'}
+ self.assertEqual(g(r), 'zh-tw')
+
def test_parse_language_cookie(self):
"""
Now test that we parse language preferences stored in a cookie correctly.