[mod] qwant: moved supported_languages to type EngineProperties
"type": "engine_properties" Supported languages in qwant are locales with a territory tag (aka regions). Moved `supported_languages` to `EngineProperties.regions`. Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
parent
3b10d63e2f
commit
da659123c1
@ -1397,6 +1397,8 @@
|
|||||||
"zh"
|
"zh"
|
||||||
],
|
],
|
||||||
"qwant": {
|
"qwant": {
|
||||||
|
"languages": {},
|
||||||
|
"regions": {
|
||||||
"bg-BG": "bg_BG",
|
"bg-BG": "bg_BG",
|
||||||
"ca-ES": "ca_ES",
|
"ca-ES": "ca_ES",
|
||||||
"cs-CZ": "cs_CZ",
|
"cs-CZ": "cs_CZ",
|
||||||
@ -1437,7 +1439,11 @@
|
|||||||
"zh-CN": "zh_CN",
|
"zh-CN": "zh_CN",
|
||||||
"zh-HK": "zh_HK"
|
"zh-HK": "zh_HK"
|
||||||
},
|
},
|
||||||
|
"type": "engine_properties"
|
||||||
|
},
|
||||||
"qwant images": {
|
"qwant images": {
|
||||||
|
"languages": {},
|
||||||
|
"regions": {
|
||||||
"bg-BG": "bg_BG",
|
"bg-BG": "bg_BG",
|
||||||
"ca-ES": "ca_ES",
|
"ca-ES": "ca_ES",
|
||||||
"cs-CZ": "cs_CZ",
|
"cs-CZ": "cs_CZ",
|
||||||
@ -1478,7 +1484,11 @@
|
|||||||
"zh-CN": "zh_CN",
|
"zh-CN": "zh_CN",
|
||||||
"zh-HK": "zh_HK"
|
"zh-HK": "zh_HK"
|
||||||
},
|
},
|
||||||
|
"type": "engine_properties"
|
||||||
|
},
|
||||||
"qwant news": {
|
"qwant news": {
|
||||||
|
"languages": {},
|
||||||
|
"regions": {
|
||||||
"ca-ES": "ca_ES",
|
"ca-ES": "ca_ES",
|
||||||
"de-AT": "de_AT",
|
"de-AT": "de_AT",
|
||||||
"de-CH": "de_CH",
|
"de-CH": "de_CH",
|
||||||
@ -1504,7 +1514,11 @@
|
|||||||
"nl-NL": "nl_NL",
|
"nl-NL": "nl_NL",
|
||||||
"pt-PT": "pt_PT"
|
"pt-PT": "pt_PT"
|
||||||
},
|
},
|
||||||
|
"type": "engine_properties"
|
||||||
|
},
|
||||||
"qwant videos": {
|
"qwant videos": {
|
||||||
|
"languages": {},
|
||||||
|
"regions": {
|
||||||
"bg-BG": "bg_BG",
|
"bg-BG": "bg_BG",
|
||||||
"ca-ES": "ca_ES",
|
"ca-ES": "ca_ES",
|
||||||
"cs-CZ": "cs_CZ",
|
"cs-CZ": "cs_CZ",
|
||||||
@ -1545,6 +1559,8 @@
|
|||||||
"zh-CN": "zh_CN",
|
"zh-CN": "zh_CN",
|
||||||
"zh-HK": "zh_HK"
|
"zh-HK": "zh_HK"
|
||||||
},
|
},
|
||||||
|
"type": "engine_properties"
|
||||||
|
},
|
||||||
"startpage": {
|
"startpage": {
|
||||||
"af": {
|
"af": {
|
||||||
"alias": "afrikaans"
|
"alias": "afrikaans"
|
||||||
|
@ -49,7 +49,7 @@ about = {
|
|||||||
# engine dependent config
|
# engine dependent config
|
||||||
categories = []
|
categories = []
|
||||||
paging = True
|
paging = True
|
||||||
supported_languages_url = about['website']
|
supported_properties_url = about['website']
|
||||||
qwant_categ = None # web|news|inages|videos
|
qwant_categ = None # web|news|inages|videos
|
||||||
|
|
||||||
safesearch = True
|
safesearch = True
|
||||||
@ -95,7 +95,7 @@ def request(query, params):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# add quant's locale
|
# add quant's locale
|
||||||
q_locale = get_engine_locale(params['language'], supported_languages, default='en_US')
|
q_locale = get_engine_locale(params['language'], supported_properties['regions'], default='en_US')
|
||||||
params['url'] += '&locale=' + q_locale
|
params['url'] += '&locale=' + q_locale
|
||||||
|
|
||||||
# add safesearch option
|
# add safesearch option
|
||||||
@ -243,7 +243,7 @@ def response(resp):
|
|||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
def _fetch_supported_languages(resp):
|
def _fetch_engine_properties(resp, engine_properties):
|
||||||
|
|
||||||
text = resp.text
|
text = resp.text
|
||||||
text = text[text.find('INITIAL_PROPS') :]
|
text = text[text.find('INITIAL_PROPS') :]
|
||||||
@ -263,8 +263,6 @@ def _fetch_supported_languages(resp):
|
|||||||
|
|
||||||
q_valid_locales.append(_locale)
|
q_valid_locales.append(_locale)
|
||||||
|
|
||||||
supported_languages = {}
|
|
||||||
|
|
||||||
for q_locale in q_valid_locales:
|
for q_locale in q_valid_locales:
|
||||||
try:
|
try:
|
||||||
locale = babel.Locale.parse(q_locale, sep='_')
|
locale = babel.Locale.parse(q_locale, sep='_')
|
||||||
@ -272,7 +270,7 @@ def _fetch_supported_languages(resp):
|
|||||||
print("ERROR: can't determine babel locale of quant's locale %s" % q_locale)
|
print("ERROR: can't determine babel locale of quant's locale %s" % q_locale)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# note: supported_languages (dict)
|
# note: engine_properties.regions (dict)
|
||||||
#
|
#
|
||||||
# dict's key is a string build up from a babel.Locale object / the
|
# dict's key is a string build up from a babel.Locale object / the
|
||||||
# notation 'xx-XX' (and 'xx') conforms to SearXNG's locale (and
|
# notation 'xx-XX' (and 'xx') conforms to SearXNG's locale (and
|
||||||
@ -280,6 +278,6 @@ def _fetch_supported_languages(resp):
|
|||||||
# the engine.
|
# the engine.
|
||||||
|
|
||||||
searxng_locale = locale.language + '-' + locale.territory # --> params['language']
|
searxng_locale = locale.language + '-' + locale.territory # --> params['language']
|
||||||
supported_languages[searxng_locale] = q_locale
|
engine_properties.regions[searxng_locale] = q_locale
|
||||||
|
|
||||||
return supported_languages
|
return engine_properties
|
||||||
|
Loading…
x
Reference in New Issue
Block a user