diff options
author | Adam Tauber <asciimoo@gmail.com> | 2018-04-05 17:27:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-05 17:27:07 +0200 |
commit | 283f6c905340087d7511bfcdb815c0b4183bcdda (patch) | |
tree | f5e450b1f02bde6fb52e7504e559fc96786ed807 /searx/query.py | |
parent | fb2dba4762541394954b295d60cb255c2785bc65 (diff) | |
parent | 772c048d01c7585fd60afca1ce30a1914e6e5b4a (diff) | |
download | searxng-283f6c905340087d7511bfcdb815c0b4183bcdda.tar.gz searxng-283f6c905340087d7511bfcdb815c0b4183bcdda.zip |
Merge pull request #1252 from MarcAbonce/search-languages
[mod] Refactor engine's search language handling
Diffstat (limited to 'searx/query.py')
-rw-r--r-- | searx/query.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/searx/query.py b/searx/query.py index 82a60e64e..0b5143d39 100644 --- a/searx/query.py +++ b/searx/query.py @@ -96,9 +96,13 @@ class RawTextQuery(object): break # user may set a valid, yet not selectable language - if not self.languages and VALID_LANGUAGE_CODE.match(lang): - self.languages.append(lang) - parse_next = True + if VALID_LANGUAGE_CODE.match(lang): + lang_parts = lang.split('-') + if len(lang_parts) > 1: + lang = lang_parts[0].lower() + '-' + lang_parts[1].upper() + if lang not in self.languages: + self.languages.append(lang) + parse_next = True # this force a engine or category if query_part[0] == '!' or query_part[0] == '?': |