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

@@ -223,7 +223,18 @@
"name": "PDF zu PNG",
"subtitle": "Jede PDF-Seite in ein PNG-Bild konvertieren.",
"imageScale": "Bildskalierung",
"imageScaleExplanation": "Höhere Skalierung = bessere Qualität, aber größere Dateigröße"
"imageScaleExplanation": "Höhere Skalierung = bessere Qualität, aber größere Dateigröße",
"alert": {
"invalidFile": "Ungültige Datei",
"invalidFileExplanation": "Bitte wähle eine PDF Datei aus.",
"noFile": "Keine Datei",
"noFileExplanation": "Bitte lade zuerst eine PDF-Datei hoch.",
"conversionSuccess": "PDF erfolgreich in PNGs konvertiert!",
"conversionError": "Konvertierung in PNG fehlgeschlagen. Die Datei könnte beschädigt sein."
},
"loader": {
"converting": "Wird in PNG konvertiert..."
}
},
"pdfToWebp": {
"name": "PDF zu WebP",

View File

@@ -223,7 +223,18 @@
"name": "PDF to PNG",
"subtitle": "Convert each PDF page into a PNG image.",
"imageScale": "Image Scale",
"imageScaleExplanation": "Higher scale = better quality but larger file size"
"imageScaleExplanation": "Higher scale = better quality but larger file size",
"alert": {
"invalidFile": "Invalid File",
"invalidFileExplanation": "Please upload a PDF file.",
"noFile": "No File",
"noFileExplanation": "Please upload a PDF file first.",
"conversionSuccess": "PDF converted to PNGs successfully!",
"conversionError": "Failed to convert PDF to PNG. The file might be corrupted."
},
"loader": {
"converting": "Converting to PNG..."
}
},
"pdfToWebp": {
"name": "PDF to WebP",

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;
}