This commit is contained in:
恍兮惚兮 2024-04-27 15:44:51 +08:00
parent 545503244d
commit d256d19bf5
3 changed files with 38 additions and 1 deletions

View File

@ -0,0 +1,25 @@
from myutils.config import static_data
import time
from translator.basetranslator import basetrans
class TS(basetrans):
def langmap(self):
x = {_: _.upper() for _ in static_data["language_list_translator_inner"]}
x.pop("cht")
return x # {"zh":"ZH","ja":"JA","en":"EN","es":"ES","fr":"FR","ru":"RU"}
def translate(self, query):
payload = {
"text": query,
"source_lang": self.srclang,
"target_lang": self.tgtlang,
}
response = self.session.post(self.config["api"], json=payload)
try:
return response.json()["data"]
except:
raise Exception(response.text)

View File

@ -856,11 +856,18 @@
"use": false, "use": false,
"color": "blue", "color": "blue",
"name": "deepl" "name": "deepl"
},"deepl2": { },
"deepl2": {
"use": false, "use": false,
"color": "blue", "color": "blue",
"name": "deepl_v2" "name": "deepl_v2"
}, },
"DeepLX": {
"use": false,
"color": "blue",
"name": "DeepLX",
"useproxy":false
},
"dev_chatgpt":{ "dev_chatgpt":{
"use": false, "use": false,
"color": "blue", "color": "blue",

View File

@ -4,6 +4,11 @@
"host": "translate.plausibility.cloud" "host": "translate.plausibility.cloud"
} }
}, },
"DeepLX":{
"args": {
"api": "https://api.deeplx.org/translate"
}
},
"baiduapi": { "baiduapi": {
"args": { "args": {
"注册网址": "https://fanyi-api.baidu.com/api/trans/product/desktop", "注册网址": "https://fanyi-api.baidu.com/api/trans/product/desktop",