diff options
author | Alexandre Flament <alex@al-f.net> | 2021-10-12 21:50:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-12 21:50:05 +0200 |
commit | ee5e9f9e1d488d8d24086b8111ac6ecff4abd77a (patch) | |
tree | 3e42dc89cfbeb1e8b33a5d30dcbfd73713e860de /tests | |
parent | b86aacdad65f8c18f01392a1a18d021006e55b21 (diff) | |
parent | 4759f65b69724589dcf1aafd04f7d7902952de98 (diff) | |
download | searxng-ee5e9f9e1d488d8d24086b8111ac6ecff4abd77a.tar.gz searxng-ee5e9f9e1d488d8d24086b8111ac6ecff4abd77a.zip |
Merge pull request #380 from dalf/fix-339
[fix] interface language zh_CN and zh_TW don't work
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/test_utils.py | 8 | ||||
-rw-r--r-- | tests/unit/test_webapp.py | 4 |
2 files changed, 10 insertions, 2 deletions
diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index e9c247382..bea28c0cc 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -92,6 +92,14 @@ class TestUtils(SearxTestCase): self.assertEqual(utils.match_language('es', [], fallback='fallback'), 'fallback') self.assertEqual(utils.match_language('ja', ['jp'], {'ja': 'jp'}), 'jp') + # handle script tags + self.assertEqual(utils.match_language('zh-CN', ['zh-Hans-CN', 'zh-Hant-TW']), 'zh-Hans-CN') + self.assertEqual(utils.match_language('zh-TW', ['zh-Hans-CN', 'zh-Hant-TW']), 'zh-Hant-TW') + self.assertEqual(utils.match_language('zh-Hans-CN', ['zh-CN', 'zh-TW']), 'zh-CN') + self.assertEqual(utils.match_language('zh-Hant-TW', ['zh-CN', 'zh-TW']), 'zh-TW') + self.assertEqual(utils.match_language('zh-Hans', ['zh-CN', 'zh-TW', 'zh-HK']), 'zh-CN') + self.assertEqual(utils.match_language('zh-Hant', ['zh-CN', 'zh-TW', 'zh-HK']), 'zh-TW') + aliases = {'en-GB': 'en-UK', 'he': 'iw'} # guess country diff --git a/tests/unit/test_webapp.py b/tests/unit/test_webapp.py index c2d57f80c..ff58aa1e9 100644 --- a/tests/unit/test_webapp.py +++ b/tests/unit/test_webapp.py @@ -211,12 +211,12 @@ class ViewsTestCase(SearxTestCase): result = self.app.get('/preferences', headers={'Accept-Language': 'zh-tw;q=0.8'}) self.assertEqual(result.status_code, 200) self.assertIn( - b'<option value="zh_TW" selected="selected">', + b'<option value="zh-Hant-TW" selected="selected">', result.data, 'Interface locale ignored browser preference.' ) self.assertIn( - b'<option value="zh-TW" selected="selected">', + b'<option value="zh-Hant-TW" selected="selected">', result.data, 'Search language ignored browser preference.' ) |