feat: add new google translate api (issue: 225, by: Bush2021)

This commit is contained in:
Gabe
2025-06-27 19:29:00 +08:00
parent d22e3838c4
commit 51f58d095a
4 changed files with 35 additions and 2 deletions

View File

@@ -2,6 +2,7 @@ import queryString from "query-string";
import { fetchData } from "../libs/fetch";
import {
OPT_TRANS_GOOGLE,
OPT_TRANS_GOOGLE2,
OPT_TRANS_MICROSOFT,
OPT_TRANS_DEEPL,
OPT_TRANS_DEEPLFREE,
@@ -259,6 +260,10 @@ export const apiTranslate = async ({
trText = res.sentences.map((item) => item.trans).join(" ");
isSame = to === res.src;
break;
case OPT_TRANS_GOOGLE2:
trText = res?.[0]?.[0]||"";
isSame = to === res.src;
break;
case OPT_TRANS_MICROSOFT:
trText = res
.map((item) => item.translations.map((item) => item.text).join(" "))