diff options
| author | Maxim Beder <macsim.beder@gmail.com> | 2021-04-30 00:40:06 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-05-05 09:37:54 +0200 |
| commit | 06fd4df41afb5aa1d681b853c3c08d8c688ca3a5 (patch) | |
| tree | ab9ee295772833a975639f3440b4569d029ab5ab /tests | |
| parent | 96f55ccf798c7592a1203f798a4dffaf173a9263 (diff) | |
Fixed #32479 -- Added fallbacks to subsequent language codes in translations.
Thanks Claude Paroz and Nick Pope for reviews.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/i18n/tests.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/i18n/tests.py b/tests/i18n/tests.py index 8248122a97..7d81f2a07d 100644 --- a/tests/i18n/tests.py +++ b/tests/i18n/tests.py @@ -1424,6 +1424,26 @@ class MiscTests(SimpleTestCase): r.META = {'HTTP_ACCEPT_LANGUAGE': 'zh-my,en'} self.assertEqual(get_language_from_request(r), 'zh-hans') + def test_subsequent_code_fallback_language(self): + """ + Subsequent language codes should be used when the language code is not + supported. + """ + tests = [ + ('zh-Hans-CN', 'zh-hans'), + ('zh-hans-mo', 'zh-hans'), + ('zh-hans-HK', 'zh-hans'), + ('zh-Hant-HK', 'zh-hant'), + ('zh-hant-tw', 'zh-hant'), + ('zh-hant-SG', 'zh-hant'), + ] + r = self.rf.get('/') + r.COOKIES = {} + for value, expected in tests: + with self.subTest(value=value): + r.META = {'HTTP_ACCEPT_LANGUAGE': f'{value},en'} + self.assertEqual(get_language_from_request(r), expected) + def test_parse_language_cookie(self): """ Now test that we parse language preferences stored in a cookie correctly. |
