Skip to content

Commit

Permalink
Merge pull request mvdctop#990 from Rhythmicc/master
Browse files Browse the repository at this point in the history
增加deeplx支持
  • Loading branch information
mvdctop authored Mar 23, 2023
2 parents 916dbd6 + 468d1ab commit 0edc5a2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 9 additions & 1 deletion ADC_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
3 changes: 2 additions & 1 deletion config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,14 @@ switch = 0
; 机器翻译
[translate]
switch = 0
;可选项 google-free,azure
;可选项 google-free,azure,deeplx
engine = google-free
; azure翻译密钥
key =
; 翻译延迟
delay = 1
values = title,outline
; google翻译服务站点,或deeplx访问链接
service_site = translate.google.cn

; 预告片
Expand Down

0 comments on commit 0edc5a2

Please sign in to comment.