From 149802c56926bf48520c98932c4c36b8152b3d2d Mon Sep 17 00:00:00 2001 From: marc Date: Fri, 5 Aug 2016 23:34:56 -0500 Subject: [enh] add supported_languages on engines and auto-generate languages.py --- searx/query.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'searx/query.py') diff --git a/searx/query.py b/searx/query.py index b8afba6ed..dcef1924d 100644 --- a/searx/query.py +++ b/searx/query.py @@ -71,21 +71,24 @@ class RawTextQuery(object): # check if any language-code is equal with # declared language-codes for lc in language_codes: - lang_id, lang_name, country = map(str.lower, lc) + lang_id, lang_name, country, english_name = map(unicode.lower, lc) # if correct language-code is found # set it as new search-language if lang == lang_id\ or lang_id.startswith(lang)\ or lang == lang_name\ + or lang == english_name\ or lang.replace('_', ' ') == country: parse_next = True - self.languages.append(lang) - break + self.languages.append(lang_id) + # to ensure best match (first match is not necessarily the best one) + if lang == lang_id: + break # this force a engine or category if query_part[0] == '!' or query_part[0] == '?': - prefix = query_part[1:].replace('_', ' ') + prefix = query_part[1:].replace('-', ' ') # check if prefix is equal with engine shortcut if prefix in engine_shortcuts: -- cgit v1.2.3