From ad964562ce249f86b806638d1eab2afc2c4ed8df Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Fri, 10 Jun 2022 17:01:12 +0200 Subject: [fix] move locale code from webapp.py to locales.py and fix #1303 To improve modularization this patch: - moves *locale* related implementation from the webapp.py application to the locale.py module. - The initialization of the locales is now done in the application (webapp) and is no longer done while importing searx.locales. In the searx.locales module a new dictionary named `LOCALE_BEST_MATCH` has been added. In this dictionary we can map languages without a translation to languages we have a translation for. To fix #1303 zh-HK has been mapped to zh-Hant-TW (we do not need additional translations of traditional Chinese) Closes: https://github.com/searxng/searxng/issues/1303 Signed-off-by: Markus Heiser --- tests/unit/test_preferences.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests') diff --git a/tests/unit/test_preferences.py b/tests/unit/test_preferences.py index 4fc6007d9..a33c78a44 100644 --- a/tests/unit/test_preferences.py +++ b/tests/unit/test_preferences.py @@ -1,3 +1,4 @@ +from searx.locales import locales_initialize from searx.preferences import ( EnumStringSetting, MapSetting, @@ -8,6 +9,8 @@ from searx.preferences import ( ) from tests import SearxTestCase +locales_initialize() + class PluginStub: def __init__(self, plugin_id, default_on): -- cgit v1.2.3