trans api return early

This commit is contained in:
Gabe Yuan
2023-11-07 17:52:33 +08:00
parent b00f636b72
commit fe13de7c30

View File

@@ -111,11 +111,15 @@ export const apiTranslate = async ({
let trText = "";
let isSame = false;
if (!text) {
return [trText, true];
}
const from =
OPT_LANGS_SPECIAL[translator].get(fromLang) ??
OPT_LANGS_SPECIAL[translator].get("auto");
const to = OPT_LANGS_SPECIAL[translator].get(toLang);
if (!text || !to) {
if (!to) {
console.log(`[trans] target lang: ${toLang} not support`);
return [trText, isSame];
}