fix: update API for Google Translate

This commit is contained in:
Bush2021
2025-04-16 18:00:54 -04:00
parent 77c6102de7
commit 84432e98ae
3 changed files with 23 additions and 22 deletions

View File

@@ -58,26 +58,16 @@ const keyPick = (translator, key = "", cacheMap) => {
};
const genGoogle = ({ text, from, to, url, key }) => {
const params = {
client: "gtx",
dt: "t",
dj: 1,
ie: "UTF-8",
sl: from,
tl: to,
q: text,
};
const input = `${url}?${queryString.stringify(params)}`;
const body = JSON.stringify([[ [text], from, to ], "wt_lib"]);
const init = {
method: "POST",
headers: {
"Content-type": "application/json",
"Content-Type": "application/json+protobuf",
"X-Goog-API-Key": key,
},
body,
};
if (key) {
init.headers.Authorization = `Bearer ${key}`;
}
return [input, init];
return [url, init];
};
const genMicrosoft = async ({ text, from, to }) => {