Add localization for PDF to WebP conversion alerts and loader messages
This commit is contained in:
@@ -240,7 +240,18 @@
|
||||
"name": "PDF zu WebP",
|
||||
"subtitle": "Jede PDF-Seite in ein WebP-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 WebPs konvertiert!",
|
||||
"conversionError": "Konvertierung in WebP fehlgeschlagen. Die Datei könnte beschädigt sein."
|
||||
},
|
||||
"loader": {
|
||||
"converting": "Wird in WebP konvertiert..."
|
||||
}
|
||||
},
|
||||
"pdfToBmp": {
|
||||
"name": "PDF zu BMP",
|
||||
|
||||
@@ -240,7 +240,18 @@
|
||||
"name": "PDF to WebP",
|
||||
"subtitle": "Convert each PDF page into a WebP 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 WebPs successfully!",
|
||||
"conversionError": "Failed to convert PDF to WebP. The file might be corrupted."
|
||||
},
|
||||
"loader": {
|
||||
"converting": "Converting to WebP..."
|
||||
}
|
||||
},
|
||||
"pdfToBmp": {
|
||||
"name": "PDF to BMP",
|
||||
|
||||
@@ -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:pdfToWebp.alert.noFile'),
|
||||
t('tools:pdfToWebp.alert.noFileExplanation')
|
||||
);
|
||||
return;
|
||||
}
|
||||
showLoader('Converting to WebP...');
|
||||
showLoader(t('tools:pdfToWebp.loader.converting'));
|
||||
try {
|
||||
const pdf = await getPDFDocument(await readFileAsArrayBuffer(files[0]))
|
||||
.promise;
|
||||
@@ -129,8 +132,8 @@ async function convert() {
|
||||
}
|
||||
|
||||
showAlert(
|
||||
'Success',
|
||||
'PDF converted to WebPs successfully!',
|
||||
t('common.success'),
|
||||
t('tools:pdfToWebp.alert.conversionSuccess'),
|
||||
'success',
|
||||
() => {
|
||||
resetState();
|
||||
@@ -138,10 +141,7 @@ async function convert() {
|
||||
);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
showAlert(
|
||||
'Error',
|
||||
'Failed to convert PDF to WebP. The file might be corrupted.'
|
||||
);
|
||||
showAlert(t('common.error'), t('tools:pdfToWebp.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:pdfToWebp.alert.invalidFile'),
|
||||
t('tools:pdfToWebp.alert.invalidFileExplanation')
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user