summaryrefslogtreecommitdiff
path: root/tests/unit/test_utils.py
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/unit/test_utils.py
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/unit/test_utils.py')
-rw-r--r--tests/unit/test_utils.py8
1 files changed, 8 insertions, 0 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