Skip to content

Commit acf8bc6

Browse files
authored
Merge pull request #1258 from hunxjunedo/dev
fix: translation not staying
2 parents 2662d07 + d36b308 commit acf8bc6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/components/cards/TranslationBox.tsx

100644100755
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export default function TranslationBox({ text, defaultLocale, disabled, textCont
6666
const [locale, setLocale] = useState("");
6767
const [loading, setLoading] = useState(false);
6868
const [description, setDescription] = useState<string | null>("");
69+
const [reverted, setReverted] =useState(false)
6970

7071
const { t } = useTranslation();
7172
const router = useRouter();
@@ -101,6 +102,7 @@ export default function TranslationBox({ text, defaultLocale, disabled, textCont
101102
}
102103

103104
setLoading(false);
105+
setReverted(false)
104106
}, [getDefaultLocale, text]);
105107

106108
/**
@@ -110,6 +112,7 @@ export default function TranslationBox({ text, defaultLocale, disabled, textCont
110112

111113
const revert = () => {
112114
setCurrentText(text);
115+
setReverted(true);
113116
setLocale(defaultLocale);
114117
};
115118

@@ -119,11 +122,12 @@ export default function TranslationBox({ text, defaultLocale, disabled, textCont
119122

120123
useEffect(() => {
121124
setDescription(translated ? t("ui.translated") : t("ui.translate"));
122-
translate();
125+
if(!translated && !reverted){
126+
translate()
127+
}
123128
}, [translated]);
124129

125130
const translatable = currentLocale !== defaultLocale && !disabled && getLocaleName(defaultLocale);
126-
127131
return (
128132
<div className="relative w-full pb-5">
129133
{currentText ? (

0 commit comments

Comments
 (0)