summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMarc Abonce Seguin <marc-abonce@mailbox.org>2021-10-04 22:44:58 -0700
committerAlexandre Flament <alex@al-f.net>2021-10-12 21:06:20 +0200
commit66b7be09656798b745f95ff0ce7669db014b3b38 (patch)
tree06b86307edb3b5c73931c29956b954ad5bf118d4 /tests
parent4cc1ee8565e22442ae92ed5f2015749d684e6087 (diff)
downloadsearxng-66b7be09656798b745f95ff0ce7669db014b3b38.tar.gz
searxng-66b7be09656798b745f95ff0ce7669db014b3b38.zip
[fix] fix match_language issue to make zh-TW match to zh-Hant-TW
pybabel separates locales with underscores but we use hyphens everywhere babel doesn't directly touch
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/test_utils.py8
-rw-r--r--tests/unit/test_webapp.py4
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..30b2839a8 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.'
)