From 571ce07af66507662193001578a76b3395b29620 Mon Sep 17 00:00:00 2001 From: Sebastian Espei Date: Tue, 10 Mar 2026 19:55:21 +0100 Subject: [PATCH] Add localization for PDF to BMP and PDF to TIFF conversion alerts and loader messages --- public/locales/de/tools.json | 26 ++++++++++++++++++++++++-- public/locales/en/tools.json | 26 ++++++++++++++++++++++++-- src/js/logic/pdf-to-bmp-page.ts | 21 ++++++++++++--------- src/js/logic/pdf-to-tiff-page.ts | 21 ++++++++++++--------- 4 files changed, 72 insertions(+), 22 deletions(-) diff --git a/public/locales/de/tools.json b/public/locales/de/tools.json index a137e1a..ab0988c 100644 --- a/public/locales/de/tools.json +++ b/public/locales/de/tools.json @@ -255,11 +255,33 @@ }, "pdfToBmp": { "name": "PDF zu BMP", - "subtitle": "Jede PDF-Seite in ein BMP-Bild konvertieren." + "subtitle": "Jede PDF-Seite in ein BMP-Bild konvertieren.", + "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 BMPs konvertiert!", + "conversionError": "Konvertierung in BMP fehlgeschlagen. Die Datei könnte beschädigt sein." + }, + "loader": { + "converting": "Wird in BMP konvertiert..." + } }, "pdfToTiff": { "name": "PDF zu TIFF", - "subtitle": "Jede PDF-Seite in ein TIFF-Bild konvertieren." + "subtitle": "Jede PDF-Seite in ein TIFF-Bild konvertieren.", + "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 TIFFs konvertiert!", + "conversionError": "Konvertierung in TIFF fehlgeschlagen. Die Datei könnte beschädigt sein." + }, + "loader": { + "converting": "Wird in TIFF konvertiert..." + } }, "pdfToGreyscale": { "name": "PDF zu Graustufen", diff --git a/public/locales/en/tools.json b/public/locales/en/tools.json index fcbb462..6fa2476 100644 --- a/public/locales/en/tools.json +++ b/public/locales/en/tools.json @@ -255,11 +255,33 @@ }, "pdfToBmp": { "name": "PDF to BMP", - "subtitle": "Convert each PDF page into a BMP image." + "subtitle": "Convert each PDF page into a BMP image.", + "alert": { + "invalidFile": "Invalid File", + "invalidFileExplanation": "Please upload a PDF file.", + "noFile": "No File", + "noFileExplanation": "Please upload a PDF file first.", + "conversionSuccess": "PDF converted to BMPs successfully!", + "conversionError": "Failed to convert PDF to BMP. The file might be corrupted." + }, + "loader": { + "converting": "Converting to BMP..." + } }, "pdfToTiff": { "name": "PDF to TIFF", - "subtitle": "Convert each PDF page into a TIFF image." + "subtitle": "Convert each PDF page into a TIFF image.", + "alert": { + "invalidFile": "Invalid File", + "invalidFileExplanation": "Please upload a PDF file.", + "noFile": "No File", + "noFileExplanation": "Please upload a PDF file first.", + "conversionSuccess": "PDF converted to TIFFs successfully!", + "conversionError": "Failed to convert PDF to TIFF. The file might be corrupted." + }, + "loader": { + "converting": "Converting to TIFF..." + } }, "pdfToGreyscale": { "name": "PDF to Greyscale", diff --git a/src/js/logic/pdf-to-bmp-page.ts b/src/js/logic/pdf-to-bmp-page.ts index e5d41fe..b38ac4d 100644 --- a/src/js/logic/pdf-to-bmp-page.ts +++ b/src/js/logic/pdf-to-bmp-page.ts @@ -92,10 +92,13 @@ const resetState = () => { async function convert() { if (files.length === 0) { - showAlert('No File', 'Please upload a PDF file first.'); + showAlert( + t('tools:pdfToBmp.alert.noFile'), + t('tools:pdfToBmp.alert.noFileExplanation') + ); return; } - showLoader('Converting to BMP...'); + showLoader(t('tools:pdfToBmp.loader.converting')); try { const pdf = await getPDFDocument(await readFileAsArrayBuffer(files[0])) .promise; @@ -119,8 +122,8 @@ async function convert() { } showAlert( - 'Success', - 'PDF converted to BMPs successfully!', + t('common.success'), + t('tools:pdfToBmp.alert.conversionSuccess'), 'success', () => { resetState(); @@ -128,10 +131,7 @@ async function convert() { ); } catch (e) { console.error(e); - showAlert( - 'Error', - 'Failed to convert PDF to BMP. The file might be corrupted.' - ); + showAlert(t('common.error'), t('tools:pdfToBmp.alert.conversionError')); } finally { hideLoader(); } @@ -175,7 +175,10 @@ document.addEventListener('DOMContentLoaded', () => { ); if (validFiles.length === 0) { - showAlert('Invalid File', 'Please upload a PDF file.'); + showAlert( + t('tools:pdfToBmp.alert.invalidFile'), + t('tools:pdfToBmp.alert.invalidFileExplanation') + ); return; } diff --git a/src/js/logic/pdf-to-tiff-page.ts b/src/js/logic/pdf-to-tiff-page.ts index 71886af..c463124 100644 --- a/src/js/logic/pdf-to-tiff-page.ts +++ b/src/js/logic/pdf-to-tiff-page.ts @@ -92,10 +92,13 @@ const resetState = () => { async function convert() { if (files.length === 0) { - showAlert('No File', 'Please upload a PDF file first.'); + showAlert( + t('tools:pdfToTiff.alert.noFile'), + t('tools:pdfToTiff.alert.noFileExplanation') + ); return; } - showLoader('Converting to TIFF...'); + showLoader(t('tools:pdfToTiff.loader.converting')); try { const pdf = await getPDFDocument(await readFileAsArrayBuffer(files[0])) .promise; @@ -122,8 +125,8 @@ async function convert() { } showAlert( - 'Success', - 'PDF converted to TIFFs successfully!', + t('common.success'), + t('tools:pdfToTiff.alert.conversionSuccess'), 'success', () => { resetState(); @@ -131,10 +134,7 @@ async function convert() { ); } catch (e) { console.error(e); - showAlert( - 'Error', - 'Failed to convert PDF to TIFF. The file might be corrupted.' - ); + showAlert(t('common.error'), t('tools:pdfToTiff.alert.conversionError')); } finally { hideLoader(); } @@ -212,7 +212,10 @@ document.addEventListener('DOMContentLoaded', () => { ); if (validFiles.length === 0) { - showAlert('Invalid File', 'Please upload a PDF file.'); + showAlert( + t('tools:pdfToTiff.alert.invalidFile'), + t('tools:pdfToTiff.alert.invalidFileExplanation') + ); return; }