Add localization for PDF to PNG conversion alerts and loader messages

This commit is contained in:
Sebastian Espei
2026-03-10 19:18:39 +01:00
parent 01c4d3bd7c
commit 37d95e249d
3 changed files with 36 additions and 11 deletions

View File

@@ -95,10 +95,13 @@ const resetState = () => {
async function convert() {
if (files.length === 0) {
showAlert('No File', 'Please upload a PDF file first.');
showAlert(
t('tools:pdfToPng.alert.noFile'),
t('tools:pdfToPng.alert.noFileExplanation')
);
return;
}
showLoader('Converting to PNG...');
showLoader(t('tools:pdfToPng.loader.converting'));
try {
const pdf = await getPDFDocument(await readFileAsArrayBuffer(files[0]))
.promise;
@@ -125,8 +128,8 @@ async function convert() {
}
showAlert(
'Success',
'PDF converted to PNGs successfully!',
t('common.success'),
t('tools:pdfToPng.alert.conversionSuccess'),
'success',
() => {
resetState();
@@ -134,10 +137,7 @@ async function convert() {
);
} catch (e) {
console.error(e);
showAlert(
'Error',
'Failed to convert PDF to PNG. The file might be corrupted.'
);
showAlert(t('common.error'), t('tools:pdfToPng.alert.conversionError'));
} finally {
hideLoader();
}
@@ -192,7 +192,10 @@ document.addEventListener('DOMContentLoaded', () => {
);
if (validFiles.length === 0) {
showAlert('Invalid File', 'Please upload a PDF file.');
showAlert(
t('tools:pdfToPng.alert.invalidFile'),
t('tools:pdfToPng.alert.invalidFileExplanation')
);
return;
}