diff --git a/public/locales/de/tools.json b/public/locales/de/tools.json index f89f6cf..09f6ebe 100644 --- a/public/locales/de/tools.json +++ b/public/locales/de/tools.json @@ -206,7 +206,18 @@ "name": "PDF zu JPG", "subtitle": "Jede PDF-Seite in ein JPG-Bild konvertieren.", "imageQuality": "Bildqualität", - "imageQualityExplanation": "Höhere Qualität = größere Dateigröße" + "imageQualityExplanation": "Höhere Qualität = 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 JPGs konvertiert!", + "conversionError": "Konvertierung in JPG fehlgeschlagen. Die Datei könnte beschädigt sein." + }, + "loader": { + "converting": "Wird in JPG konvertiert..." + } }, "pdfToPng": { "name": "PDF zu PNG", diff --git a/public/locales/en/tools.json b/public/locales/en/tools.json index 16a825b..f446c8d 100644 --- a/public/locales/en/tools.json +++ b/public/locales/en/tools.json @@ -206,7 +206,18 @@ "name": "PDF to JPG", "subtitle": "Convert each PDF page into a JPG image.", "imageQuality": "Image Quality", - "imageQualityExplanation": "Higher quality = larger file size" + "imageQualityExplanation": "Higher quality = 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 JPGs successfully!", + "conversionError": "Failed to convert PDF to JPG. The file might be corrupted." + }, + "loader": { + "converting": "Converting to JPG..." + } }, "pdfToPng": { "name": "PDF to PNG", diff --git a/src/js/logic/pdf-to-jpg-page.ts b/src/js/logic/pdf-to-jpg-page.ts index af73aeb..dedebb3 100644 --- a/src/js/logic/pdf-to-jpg-page.ts +++ b/src/js/logic/pdf-to-jpg-page.ts @@ -97,10 +97,13 @@ const resetState = () => { async function convert() { if (files.length === 0) { - showAlert('No File', 'Please upload a PDF file first.'); + showAlert( + t('tools:pdfToJpg.alert.noFile'), + t('tools:pdfToJpg.alert.noFileExplanation') + ); return; } - showLoader('Converting to JPG...'); + showLoader(t('tools:pdfToJpg.loader.converting')); try { const pdf = await getPDFDocument(await readFileAsArrayBuffer(files[0])) .promise; @@ -129,8 +132,8 @@ async function convert() { } showAlert( - 'Success', - 'PDF converted to JPGs successfully!', + t('common.success'), + t('tools:pdfToJpg.alert.conversionSuccess'), 'success', () => { resetState(); @@ -138,10 +141,7 @@ async function convert() { ); } catch (e) { console.error(e); - showAlert( - 'Error', - 'Failed to convert PDF to JPG. The file might be corrupted.' - ); + showAlert(t('common.error'), t('tools:pdfToJpg.alert.conversionError')); } finally { hideLoader(); } @@ -198,7 +198,10 @@ document.addEventListener('DOMContentLoaded', () => { ); if (validFiles.length === 0) { - showAlert('Invalid File', 'Please upload a PDF file.'); + showAlert( + t('tools:pdfToJpg.alert.invalidFile'), + t('tools:pdfToJpg.alert.invalidFileExplanation') + ); return; }