[fix] deepl

This commit is contained in:
kwaroran
2023-11-28 04:40:30 +09:00
parent 220c2c091b
commit 60f836e21f

View File

@@ -105,17 +105,18 @@ async function translateMain(text:string, arg:{from:string, to:string, host:stri
return translateLLM(text, {to: tr}) return translateLLM(text, {to: tr})
} }
if(db.translatorType === 'deepl'){ if(db.translatorType === 'deepl'){
const body = {
text: [text],
source_lang: arg.from.toLocaleUpperCase(),
target_lang: arg.to.toLocaleUpperCase(),
}
let url = db.deeplOptions.freeApi ? "https://api-free.deepl.com/v2/translate" : "https://api.deepl.com/v2/translate" let url = db.deeplOptions.freeApi ? "https://api-free.deepl.com/v2/translate" : "https://api.deepl.com/v2/translate"
const f = await globalFetch(url, { const f = await globalFetch(url, {
headers: { headers: {
"Authorization": "DeepL-Auth-Key " + db.deeplOptions.key, "Authorization": "DeepL-Auth-Key " + db.deeplOptions.key,
"Content-Type": "application/json" "Content-Type": "application/json"
}, },
body: { body: body
text: text,
source_lang: arg.from.toLocaleUpperCase(),
target_lang: arg.to.toLocaleUpperCase(),
}
}) })
if(!f.ok){ if(!f.ok){