Add localization for PDF to WebP conversion alerts and loader messages

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

View File

@@ -240,7 +240,18 @@
"name": "PDF zu WebP", "name": "PDF zu WebP",
"subtitle": "Jede PDF-Seite in ein WebP-Bild konvertieren.", "subtitle": "Jede PDF-Seite in ein WebP-Bild konvertieren.",
"imageQuality": "Bildqualität", "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 WebPs konvertiert!",
"conversionError": "Konvertierung in WebP fehlgeschlagen. Die Datei könnte beschädigt sein."
},
"loader": {
"converting": "Wird in WebP konvertiert..."
}
}, },
"pdfToBmp": { "pdfToBmp": {
"name": "PDF zu BMP", "name": "PDF zu BMP",

View File

@@ -240,7 +240,18 @@
"name": "PDF to WebP", "name": "PDF to WebP",
"subtitle": "Convert each PDF page into a WebP image.", "subtitle": "Convert each PDF page into a WebP image.",
"imageQuality": "Image Quality", "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 WebPs successfully!",
"conversionError": "Failed to convert PDF to WebP. The file might be corrupted."
},
"loader": {
"converting": "Converting to WebP..."
}
}, },
"pdfToBmp": { "pdfToBmp": {
"name": "PDF to BMP", "name": "PDF to BMP",

View File

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