Add localization for PDF to JPG conversion alerts and loader messages
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user