fix: remove hardcoded English from alerts and pass errors verbatim
- Replace English wrapper text in error alerts with direct error.message - Use existing translation keys where available (pleaseEnterTranslateText, pleaseSelectFile) - Remove unnecessary alerts for modal failures and operation errors - All error messages now passed through verbatim without English text
This commit is contained in:
parent
f87f59c194
commit
988349b67e
5 changed files with 15 additions and 21 deletions
|
|
@ -35,7 +35,7 @@ export function hideProgressIndicator() {
|
|||
export async function handleFileUpload() {
|
||||
const fileInput = document.getElementById("file-input");
|
||||
if (!fileInput.files[0]) {
|
||||
alert("Please select a file first.");
|
||||
alert(getUIText("pleaseSelectFile"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -48,7 +48,6 @@ export async function handleFileUpload() {
|
|||
fileInput.value = ""; // Clear the input after upload
|
||||
} catch (error) {
|
||||
console.error("File upload error:", error);
|
||||
alert("Failed to upload the file.");
|
||||
hideProgressIndicator();
|
||||
}
|
||||
}
|
||||
|
|
@ -114,7 +113,6 @@ export async function integrateMegafarceResponse(response) {
|
|||
chatBox.appendChild(downloadButton);
|
||||
} catch (error) {
|
||||
console.error("Error generating TTS:", error);
|
||||
alert("Failed to generate TTS for the uploaded content.");
|
||||
generateTTSButton.textContent = "Generate TTS for Uploaded Content";
|
||||
generateTTSButton.disabled = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -173,10 +173,8 @@ export function addRefreshModelsButton() {
|
|||
});
|
||||
}
|
||||
|
||||
alert("Models refreshed successfully!");
|
||||
} catch (error) {
|
||||
console.error("Error refreshing models:", error);
|
||||
alert("Failed to refresh models. Please try again.");
|
||||
} finally {
|
||||
refreshButton.textContent = "Refresh Models";
|
||||
refreshButton.disabled = false;
|
||||
|
|
|
|||
|
|
@ -293,7 +293,7 @@ ${preservedText}`;
|
|||
} else {
|
||||
const customText = textArea.value.trim();
|
||||
if (!customText) {
|
||||
alert("Please enter some text to translate!");
|
||||
alert(getUIText("pleaseEnterTranslateText"));
|
||||
return;
|
||||
}
|
||||
translatedText = await translateText(customText, targetLanguage);
|
||||
|
|
@ -427,7 +427,7 @@ ${preservedText}`;
|
|||
if (progressContainer && progressContainer.parentNode) {
|
||||
progressContainer.parentNode.removeChild(progressContainer);
|
||||
}
|
||||
alert(`Translation failed: ${error.message}`);
|
||||
alert(error.message);
|
||||
} finally {
|
||||
translateButton.textContent = isPageMode
|
||||
? "🌐 Translate Page"
|
||||
|
|
|
|||
|
|
@ -691,7 +691,6 @@ async function openUncloseaiEmbeddedModalNew() {
|
|||
openTTSModal();
|
||||
} catch (error) {
|
||||
console.error("Failed to open TTS modal:", error);
|
||||
alert("TTS modal is not available at the moment.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -709,7 +708,6 @@ async function openUncloseaiEmbeddedModalNew() {
|
|||
openTranslateModal();
|
||||
} catch (error) {
|
||||
console.error("Failed to open translate modal:", error);
|
||||
alert("Translation modal is not available at the moment.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -921,7 +919,7 @@ async function openUncloseaiEmbeddedModalNew() {
|
|||
userTtsBtn.textContent = "🔊";
|
||||
}
|
||||
} catch (error) {
|
||||
alert(`User TTS failed: ${error.message}`);
|
||||
alert(error.message);
|
||||
userTtsBtn.textContent = originalText;
|
||||
userTtsBtn.title = originalTitle;
|
||||
} finally {
|
||||
|
|
@ -1114,7 +1112,7 @@ async function openUncloseaiEmbeddedModalNew() {
|
|||
}
|
||||
} catch (error) {
|
||||
console.error("🔊 CHAT TTS: Failed with error:", error);
|
||||
alert(`Chat TTS failed: ${error.message}`);
|
||||
alert(error.message);
|
||||
ttsBtn.textContent = originalText;
|
||||
ttsBtn.title = originalTitle;
|
||||
} finally {
|
||||
|
|
@ -1161,7 +1159,7 @@ async function openUncloseaiEmbeddedModalNew() {
|
|||
copyRawBtn.textContent = originalText;
|
||||
}, 1000);
|
||||
} catch (error) {
|
||||
alert(`Failed to copy: ${error.message}`);
|
||||
alert(error.message);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -1180,7 +1178,7 @@ async function openUncloseaiEmbeddedModalNew() {
|
|||
copyHtmlBtn.textContent = originalText;
|
||||
}, 1000);
|
||||
} catch (error) {
|
||||
alert(`Failed to copy: ${error.message}`);
|
||||
alert(error.message);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -1445,7 +1443,7 @@ You have complete knowledge of this page content and can reference any details,
|
|||
userTtsBtn.textContent = "🔊";
|
||||
}
|
||||
} catch (error) {
|
||||
alert(`User TTS failed: ${error.message}`);
|
||||
alert(error.message);
|
||||
userTtsBtn.textContent = originalText;
|
||||
userTtsBtn.title = originalTitle;
|
||||
} finally {
|
||||
|
|
@ -1609,7 +1607,7 @@ You have complete knowledge of this page content and can reference any details,
|
|||
}
|
||||
} catch (error) {
|
||||
console.error("🔊 HISTORICAL TTS: Failed with error:", error);
|
||||
alert(`Historical TTS failed: ${error.message}`);
|
||||
alert(error.message);
|
||||
ttsBtn.textContent = originalText;
|
||||
} finally {
|
||||
ttsBtn.disabled = false;
|
||||
|
|
@ -1651,7 +1649,7 @@ You have complete knowledge of this page content and can reference any details,
|
|||
copyRawBtn.textContent = originalText;
|
||||
}, 1000);
|
||||
} catch (error) {
|
||||
alert(`Failed to copy: ${error.message}`);
|
||||
alert(error.message);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -1670,7 +1668,7 @@ You have complete knowledge of this page content and can reference any details,
|
|||
copyHtmlBtn.textContent = originalText;
|
||||
}, 1000);
|
||||
} catch (error) {
|
||||
alert(`Failed to copy: ${error.message}`);
|
||||
alert(error.message);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -1859,7 +1857,7 @@ You have complete knowledge of this page content and can reference any details,
|
|||
}
|
||||
} catch (error) {
|
||||
console.error("🔊 INTRO TTS: Failed with error:", error);
|
||||
alert(`Intro TTS failed: ${error.message}`);
|
||||
alert(error.message);
|
||||
ttsBtn.textContent = originalText;
|
||||
} finally {
|
||||
ttsBtn.disabled = false;
|
||||
|
|
@ -1901,7 +1899,7 @@ You have complete knowledge of this page content and can reference any details,
|
|||
copyRawBtn.textContent = originalText;
|
||||
}, 1000);
|
||||
} catch (error) {
|
||||
alert(`Failed to copy: ${error.message}`);
|
||||
alert(error.message);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -1920,7 +1918,7 @@ You have complete knowledge of this page content and can reference any details,
|
|||
copyHtmlBtn.textContent = originalText;
|
||||
}, 1000);
|
||||
} catch (error) {
|
||||
alert(`Failed to copy: ${error.message}`);
|
||||
alert(error.message);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -345,7 +345,7 @@ export async function handleSmartTranslate(button) {
|
|||
// Close dropdown
|
||||
dropdown.remove();
|
||||
} catch (error) {
|
||||
alert(`Translation failed: ${error.message}`);
|
||||
alert(error.message);
|
||||
// Restore original format
|
||||
option.innerHTML = `
|
||||
<span style="font-family: monospace; color: ${colors.mutedText}; font-size: 12px; min-width: 24px;">${code}</span>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue