diff options
author | Markus Heiser <markus.heiser@darmarit.de> | 2022-08-01 17:01:59 +0200 |
---|---|---|
committer | Markus Heiser <markus.heiser@darmarit.de> | 2022-08-01 17:01:59 +0200 |
commit | 8df1f0c47e03fe7525c40a2856dba950bab8998b (patch) | |
tree | 844dc7ca4d31f0ff97c07d1817dbfba591420b30 /searx/search/models.py | |
parent | a2badb4fe47eaa6df26b7bc0ef601cb9179edc3a (diff) | |
download | searxng-8df1f0c47e03fe7525c40a2856dba950bab8998b.tar.gz searxng-8df1f0c47e03fe7525c40a2856dba950bab8998b.zip |
[mod] add 'Accept-Language' HTTP header to online processores
Most engines that support languages (and regions) use the Accept-Language from
the WEB browser to build a response that fits to the language (and region).
- add new engine option: send_accept_language_header
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'searx/search/models.py')
-rw-r--r-- | searx/search/models.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/searx/search/models.py b/searx/search/models.py index ff5897966..bbca1cd1d 100644 --- a/searx/search/models.py +++ b/searx/search/models.py @@ -1,6 +1,7 @@ # SPDX-License-Identifier: AGPL-3.0-or-later import typing +import babel class EngineRef: @@ -29,6 +30,7 @@ class SearchQuery: 'query', 'engineref_list', 'lang', + 'locale', 'safesearch', 'pageno', 'time_range', @@ -59,6 +61,13 @@ class SearchQuery: self.external_bang = external_bang self.engine_data = engine_data or {} + self.locale = None + if self.lang: + try: + self.locale = babel.Locale.parse(self.lang, sep='-') + except babel.core.UnknownLocaleError: + pass + @property def categories(self): return list(set(map(lambda engineref: engineref.category, self.engineref_list))) |