summaryrefslogtreecommitdiff
path: root/searx/preferences.py
diff options
context:
space:
mode:
authorNicolas Gelot <nicofonk@gmail.com>2019-03-28 18:07:03 +0100
committerNicolas Gelot <nicofonk@gmail.com>2019-06-17 23:19:15 +0200
commit373a66be3046bbb7deca20f08468cb5dea44eaf9 (patch)
tree3962814873918aa7ed07dd634c44ca67f193ca9b /searx/preferences.py
parenta818d3241df2cf010086f837a504b11983c3d55f (diff)
Fix locale and search language
Locale and search language was always defined with english value. This patch inits the locale on `pre_request` in order to define the default value of locale and language preferences. Plus the `best_match` function provided by flask babel library did not work as expected. So the function `match_language` provided by searx is used to detect that the language from Accepted-Language header can be used in searx project.
Diffstat (limited to 'searx/preferences.py')
-rw-r--r--searx/preferences.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/searx/preferences.py b/searx/preferences.py
index acaa67f66..912e89c01 100644
--- a/searx/preferences.py
+++ b/searx/preferences.py
@@ -243,8 +243,8 @@ class Preferences(object):
super(Preferences, self).__init__()
self.key_value_settings = {'categories': MultipleChoiceSetting(['general'], choices=categories + ['none']),
- 'language': SearchLanguageSetting(settings['search']['language'],
- choices=LANGUAGE_CODES),
+ 'language': SearchLanguageSetting(settings['ui']['default_locale'],
+ choices=list(LANGUAGE_CODES) + ['']),
'locale': EnumStringSetting(settings['ui']['default_locale'],
choices=list(settings['locales'].keys()) + ['']),
'autocomplete': EnumStringSetting(settings['search']['autocomplete'],