mirror of https://github.com/searxng/searxng.git
[mod] libretranslate: add direct link to translation (engine)
This commit is contained in:
parent
adaec68728
commit
39aaac40d6
|
@ -31,6 +31,7 @@ def request(_query, params):
|
||||||
|
|
||||||
params['method'] = 'POST'
|
params['method'] = 'POST'
|
||||||
params['headers'] = {'Content-Type': 'application/json'}
|
params['headers'] = {'Content-Type': 'application/json'}
|
||||||
|
params['req_url'] = request_url
|
||||||
|
|
||||||
return params
|
return params
|
||||||
|
|
||||||
|
@ -40,7 +41,13 @@ def response(resp):
|
||||||
|
|
||||||
json_resp = resp.json()
|
json_resp = resp.json()
|
||||||
text = json_resp.get('translatedText')
|
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:
|
if text:
|
||||||
results.append({'answer': text})
|
results.append({"answer": text, "url": f"{req_url}/?source={from_lang}&target={to_lang}&q={query}"})
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
Loading…
Reference in New Issue