forked from Ponysearch/Ponysearch
[mod] libretranslate: add direct link to translation (engine)
This commit is contained in:
parent
adaec68728
commit
39aaac40d6
1 changed files with 8 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue