summaryrefslogtreecommitdiff
path: root/searx/engines
diff options
context:
space:
mode:
authorThomas Renard <Thomas.Renard@g3la.de>2024-06-29 12:39:31 +0200
committerBnyro <bnyro@tutanota.com>2024-06-30 16:18:33 +0200
commit39aaac40d63d53555b7fc12d56f0825c85ecf567 (patch)
tree3a0b16d2a84548011e77f6833b88146bc7a12e6d /searx/engines
parentadaec68728871ab7ee7ff1f4bcf42a8156b7aac4 (diff)
downloadsearxng-39aaac40d63d53555b7fc12d56f0825c85ecf567.tar.gz
searxng-39aaac40d63d53555b7fc12d56f0825c85ecf567.zip
[mod] libretranslate: add direct link to translation (engine)
Diffstat (limited to 'searx/engines')
-rw-r--r--searx/engines/libretranslate.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/searx/engines/libretranslate.py b/searx/engines/libretranslate.py
index 20fa481f5..a62d88d8a 100644
--- a/searx/engines/libretranslate.py
+++ b/searx/engines/libretranslate.py
@@ -31,6 +31,7 @@ def request(_query, params):
params['method'] = 'POST'
params['headers'] = {'Content-Type': 'application/json'}
+ params['req_url'] = request_url
return params
@@ -40,7 +41,13 @@ def response(resp):
json_resp = resp.json()
text = json_resp.get('translatedText')
+
+ from_lang = resp.search_params["from_lang"][1]
+ to_lang = resp.search_params["to_lang"][1]
+ query = resp.search_params["query"]
+ req_url = resp.search_params["req_url"]
+
if text:
- results.append({'answer': text})
+ results.append({"answer": text, "url": f"{req_url}/?source={from_lang}&target={to_lang}&q={query}"})
return results