Fixed a mistake in translateHTML.

This commit is contained in:
sub-hub
2024-05-06 17:14:27 +09:00
parent 9b3571beeb
commit ca57cf6108

View File

@@ -316,7 +316,6 @@ export async function translateHTML(html: string, reverse:boolean, charArg:simpl
let translated = await translate(node.textContent || "", reverse); let translated = await translate(node.textContent || "", reverse);
if (!reprocessDisplayScript) { if (!reprocessDisplayScript) {
node.textContent = translated; node.textContent = translated;
applyMarkdownToNode(node);
return; return;
} }
@@ -326,6 +325,12 @@ export async function translateHTML(html: string, reverse:boolean, charArg:simpl
"editdisplay", "editdisplay",
chatID chatID
); );
// If the translation is the same, don't replace the node
if (translated == processedTranslated) {
node.textContent = processedTranslated;
applyMarkdownToNode(node)
return;
}
// Replace the old node with the new one // Replace the old node with the new one
const newNode = document.createElement( const newNode = document.createElement(