fix: try detect language only when fromLang is auto

This commit is contained in:
Gabe Yuan
2024-05-30 21:05:05 +08:00
parent 0bfa5256b8
commit d6fe1ce9d7
2 changed files with 9 additions and 6 deletions

View File

@@ -34,7 +34,7 @@ export default function TranCont({
setError("");
let to = toLang;
if (toLang !== toLang2 && toLang2 !== "none") {
if (fromLang === "auto" && toLang !== toLang2 && toLang2 !== "none") {
const detectLang = await tryDetectLang(text, true, langDetector);
if (detectLang === toLang) {
to = toLang2;