summaryrefslogtreecommitdiff
path: root/searx/engines/qwant.py
diff options
context:
space:
mode:
authormarc <a01200356@itesm.mx>2016-10-29 21:04:01 -0500
committermarc <a01200356@itesm.mx>2016-12-13 19:32:43 -0600
commita11948c71bfe7b2aac6e50e7634874d5073c7d84 (patch)
treec5d5c52ca459ba89b2e36d2e87ce3e250be6c896 /searx/engines/qwant.py
parenta11230819ff76312b4528b2bfb6e03d0560075b1 (diff)
downloadsearxng-a11948c71bfe7b2aac6e50e7634874d5073c7d84.tar.gz
searxng-a11948c71bfe7b2aac6e50e7634874d5073c7d84.zip
Add language support for more engines.
Diffstat (limited to 'searx/engines/qwant.py')
-rw-r--r--searx/engines/qwant.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/searx/engines/qwant.py b/searx/engines/qwant.py
index d8b084292..200e9ada9 100644
--- a/searx/engines/qwant.py
+++ b/searx/engines/qwant.py
@@ -20,6 +20,11 @@ from searx.utils import html_to_text
categories = None
paging = True
language_support = True
+supported_languages = ["fr-FR", "de-DE", "en-GB", "it-IT", "es-ES", "pt-PT", "de-CH", "fr-CH", "it-CH", "de-AT",
+ "fr-BE", "nl-BE", "nl-NL", "da-DK", "fi-FI", "sv-SE", "en-IE", "no-NO", "pl-PL", "ru-RU",
+ "el-GR", "bg-BG", "cs-CZ", "et-EE", "hu-HU", "ro-RO", "en-US", "en-CA", "fr-CA", "pt-BR",
+ "es-AR", "es-CL", "es-MX", "ja-JP", "en-SG", "en-IN", "en-MY", "ms-MY", "ko-KR", "tl-PH",
+ "th-TH", "he-IL", "tr-TR", "en-AU", "en-NZ"]
category_to_keyword = {'general': 'web',
'images': 'images',
@@ -46,7 +51,15 @@ def request(query, params):
# add language tag if specified
if params['language'] != 'all':
- params['url'] += '&locale=' + params['language'].lower()
+ locale = params['language'].split('-')
+ if len(locale) == 2 and params['language'] in supported_languages:
+ params['url'] += '&locale=' + params['language'].replace('-', '_').lower()
+ else:
+ # try to get a country code for language
+ for lang in supported_languages:
+ if locale[0] == lang.split('-')[0]:
+ params['url'] += '&locale=' + lang.replace('-', '_').lower()
+ break
return params