diff --git a/public/locales/de/tools.json b/public/locales/de/tools.json index 09f6ebe..eef2bf6 100644 --- a/public/locales/de/tools.json +++ b/public/locales/de/tools.json @@ -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", diff --git a/public/locales/en/tools.json b/public/locales/en/tools.json index f446c8d..043c880 100644 --- a/public/locales/en/tools.json +++ b/public/locales/en/tools.json @@ -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", diff --git a/src/js/logic/pdf-to-png-page.ts b/src/js/logic/pdf-to-png-page.ts index 76a3706..84fe5e5 100644 --- a/src/js/logic/pdf-to-png-page.ts +++ b/src/js/logic/pdf-to-png-page.ts @@ -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; }