Repository: searx/searx

Issue:
Google engine crashes when language selected
<!-- PLEASE FILL THESE FIELDS, IT REALLY HELPS THE MAINTAINERS OF SEARX -->

**Version of Searx, commit number if you are using on master branch and stipulate if you forked Searx**

1.0.0-185-efe730fb

**How did you install Searx?**

https://github.com/k8s-at-home/charts/tree/master/charts/stable/searx

with some configuration

**What happened?**

Searx engines `google-de` and `google-en` used to bring multi-language search support crash due to imperfect parameter/object passing within code.


**How To Reproduce**
<!-- How can we reproduce this issue? (as minimally and as precisely as possible) -->

configure engines:

```
  - name : google-de
    engine : google
    language : de_DE
    shortcut : go_de
    use_mobile_ui: false

  - name : google-en
    engine : google
    language : en_US
    shortcut : go_en
    use_mobile_ui: false
```

and try.

same with language = 'en-US', 'de-DE', 'English', 'english', 'Deutsch', 'german'

**Expected behavior**

Results with english preferred come via `google-en`, results with german preferred come via `google-de`.

**Screenshots & Logs**

```
ERROR:searx.search.processor.online:engine google-de : exception : 'list' object has no attribute 'get'
Traceback (most recent call last):
  File "/usr/local/searx/searx/search/processors/online.py", line 139, in search
    search_results = self._search_basic(query, params)
  File "/usr/local/searx/searx/search/processors/online.py", line 109, in _search_basic
    self.engine.request(query, params)
  File "/usr/local/searx/searx/engines/google.py", line 205, in request
    lang_info = get_lang_info(
  File "/usr/local/searx/searx/engines/google.py", line 185, in get_lang_info
    ret_val['params']['lr'] = "lang_" + lang_list.get(lang_country, language)
AttributeError: 'list' object has no attribute 'get'
ERROR:searx.search.processor.online:engine google-en : exception : 'list' object has no attribute 'get'
Traceback (most recent call last):
  File "/usr/local/searx/searx/search/processors/online.py", line 139, in search
    search_results = self._search_basic(query, params)
  File "/usr/local/searx/searx/search/processors/online.py", line 109, in _search_basic
    self.engine.request(query, params)
  File "/usr/local/searx/searx/engines/google.py", line 205, in request
    lang_info = get_lang_info(
  File "/usr/local/searx/searx/engines/google.py", line 185, in get_lang_info
    ret_val['params']['lr'] = "lang_" + lang_list.get(lang_country, language)
AttributeError: 'list' object has no attribute 'get'
```

**Additional context**

related to https://github.com/searx/searx/issues/1344

I'm also not sure whether passing the language to the `bing` and `startpage` engines does anything at all.


Discussion:

Resolving patch:
diff --git a/searx/engines/__init__.py b/searx/engines/__init__.py
--- a/searx/engines/__init__.py
+++ b/searx/engines/__init__.py
@@ -108,8 +108,8 @@ def load_engine(engine_data):
             sys.exit(1)
 
     # assign supported languages from json file
-    if engine_data['name'] in ENGINES_LANGUAGES:
-        setattr(engine, 'supported_languages', ENGINES_LANGUAGES[engine_data['name']])
+    if engine_data['engine'] in ENGINES_LANGUAGES:
+        setattr(engine, 'supported_languages', ENGINES_LANGUAGES[engine_data['engine']])
 
     # find custom aliases for non standard language codes
     if hasattr(engine, 'supported_languages'):


Test patch: