diff options
author | Alexandre Flament <alex@al-f.net> | 2021-10-21 10:41:57 +0200 |
---|---|---|
committer | Alexandre Flament <alex@al-f.net> | 2021-10-26 10:27:05 +0200 |
commit | 60db344cc0715eab4d03dad5629f4c47954c466c (patch) | |
tree | ed933547df3bc250d1cac558cb37be0f6b9ba93a /searx/webapp.py | |
parent | dfdf71bf08d48332a30ff982dcc8b4ac499d9c8d (diff) | |
download | searxng-60db344cc0715eab4d03dad5629f4c47954c466c.tar.gz searxng-60db344cc0715eab4d03dad5629f4c47954c466c.zip |
[enh] reduce the available language list
close #406
settings['search']['languages'] contains the languages codes and 'all'
Diffstat (limited to 'searx/webapp.py')
-rwxr-xr-x | searx/webapp.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/searx/webapp.py b/searx/webapp.py index e8fb92565..ee558a5f7 100755 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -90,7 +90,6 @@ from searx.plugins.oa_doi_rewrite import get_doi_resolver from searx.preferences import ( Preferences, ValidationException, - LANGUAGE_CODES, ) from searx.answerers import ( answerers, @@ -432,7 +431,7 @@ def render(template_name, override_theme=None, **kwargs): kwargs['categories'] = _get_enable_categories(kwargs['all_categories']) # i18n - kwargs['language_codes'] = languages # from searx.languages + kwargs['language_codes'] = [ l for l in languages if l[0] in settings['search']['languages'] ] kwargs['translations'] = json.dumps(get_translations(), separators=(',', ':')) locale = request.preferences.get_value('locale') @@ -442,7 +441,7 @@ def render(template_name, override_theme=None, **kwargs): kwargs['rtl'] = True if 'current_language' not in kwargs: kwargs['current_language'] = match_language( - request.preferences.get_value('language'), LANGUAGE_CODES ) + request.preferences.get_value('language'), settings['search']['languages'] ) # values from settings kwargs['search_formats'] = [ @@ -524,7 +523,7 @@ def pre_request(): # language is defined neither in settings nor in preferences # use browser headers if not preferences.get_value("language"): - language = _get_browser_language(request, LANGUAGE_CODES) + language = _get_browser_language(request, settings['search']['languages']) preferences.parse_dict({"language": language}) # locale is defined neither in settings nor in preferences @@ -807,7 +806,7 @@ def search(): ), current_language = match_language( search_query.lang, - LANGUAGE_CODES, + settings['search']['languages'], fallback=request.preferences.get_value("language") ), theme = get_current_theme_name(), |