增加deeplx支持

This commit is contained in:
Rhythmicc
2023-03-21 21:10:42 +08:00
parent 916dbd6abc
commit 468d1ab671
2 changed files with 11 additions and 2 deletions

View File

@@ -342,7 +342,15 @@ def translate(
result = post_html(url=url, query=body, headers=headers)
translate_list = [i["text"] for i in result.json()[0]["translations"]]
trans_result = trans_result.join(translate_list)
elif engine == "deeplx":
url = config.getInstance().get_translate_service_site()
res = requests.post(f"{url}/translate", json={
'text': src,
'source_lang': 'auto',
'target_lang': target_language,
})
if res.text.strip():
trans_result = res.json().get('data')
else:
raise ValueError("Non-existent translation engine")