diff --git a/src/main/resources/messages_en_GB.properties b/src/main/resources/messages_en_GB.properties index b8c44321..c5e42bff 100644 --- a/src/main/resources/messages_en_GB.properties +++ b/src/main/resources/messages_en_GB.properties @@ -965,6 +965,16 @@ multiTool.dragDropMessage=Page(s) Selected multiTool.undo=Undo multiTool.redo=Redo +#multiTool-decrypt +multiTool.decrypt.passwordPrompt=This file is password-protected. Please enter the password: +multiTool.decrypt.cancelled=Operation cancelled for PDF: {0} +multiTool.decrypt.noPassword=No password provided for encrypted PDF: {0} +multiTool.decrypt.invalidPassword=Please try again with the correct password. +multiTool.decrypt.invalidPasswordHeader=Incorrect password for PDF: {0} +multiTool.decrypt.unexpectedError=There was an error processing the file. Please try again. +multiTool.decrypt.serverError=Server error while decrypting: {0} +multiTool.decrypt.success=File decrypted successfully. + #multiTool-advert multiTool-advert.message=This feature is also available in our multi-tool page. Check it out for enhanced page-by-page UI and additional features! diff --git a/src/main/resources/static/js/multitool/DecryptFiles.js b/src/main/resources/static/js/multitool/DecryptFiles.js index bd7e0073..a9acbccc 100644 --- a/src/main/resources/static/js/multitool/DecryptFiles.js +++ b/src/main/resources/static/js/multitool/DecryptFiles.js @@ -6,14 +6,22 @@ export class DecryptFile { if (password === null) { // User cancelled console.error(`Password prompt cancelled for PDF: ${file.name}`); - this.showErrorBanner(`Operation cancelled for PDF: ${file.name}`, 'You cancelled the decryption process.'); + this.showErrorBanner( + `${window.translations.cancelled.replace('{0}', file.name)}`, + '', + `${window.translations.unexpectedError}` + ); return null; // No file to return } if (!password) { // No password provided console.error(`No password provided for encrypted PDF: ${file.name}`); - this.showErrorBanner(`No password provided for encrypted PDF: ${file.name}`, 'Please enter a valid password.'); + this.showErrorBanner( + `${window.translations.noPassword.replace('{0}', file.name)}`, + '', + `${window.translations.unexpectedError}` + ); return null; // No file to return } @@ -33,11 +41,11 @@ export class DecryptFile { return new File([decryptedBlob], file.name, {type: 'application/pdf'}); } else { const errorText = await response.text(); - console.error(`Server error while decrypting: ${errorText}`); + console.error(`${window.translations.invalidPassword} ${errorText}`); this.showErrorBanner( - 'Please try again with the correct password.', + `${window.translations.invalidPassword}`, errorText, - `Incorrect password for PDF: ${file.name}` + `${window.translations.invalidPasswordHeader.replace('{0}', file.name)}` ); return null; // No file to return } @@ -45,9 +53,9 @@ export class DecryptFile { // Handle network or unexpected errors console.error(`Failed to decrypt PDF: ${file.name}`, error); this.showErrorBanner( - `Decryption error for PDF: ${file.name}`, - error.message || 'Unexpected error occurred.', - 'There was an error processing the file. Please try again.' + `${window.translations.unexpectedError.replace('{0}', file.name)}`, + `${error.message || window.translations.unexpectedError}`, + error ); return null; // No file to return } diff --git a/src/main/resources/templates/multi-tool.html b/src/main/resources/templates/multi-tool.html index 14e5a85e..532ca5f8 100644 --- a/src/main/resources/templates/multi-tool.html +++ b/src/main/resources/templates/multi-tool.html @@ -162,7 +162,15 @@ insertPageBreak:'[[#{multiTool.insertPageBreak}]]', dragDropMessage:'[[#{multiTool.dragDropMessage}]]', undo: '[[#{multiTool.undo}]]', - redo: '[[#{multiTool.redo}]]' + redo: '[[#{multiTool.redo}]]', + passwordPrompt: '[[#{multiTool.decrypt.passwordPrompt}]]', + cancelled: '[[#{multiTool.decrypt.cancelled}]]', + noPassword: '[[#{multiTool.decrypt.noPassword}]]', + invalidPassword: '[[#{multiTool.decrypt.invalidPassword}]]', + invalidPasswordHeader: '[[#{multiTool.decrypt.invalidPasswordHeader}]]', + unexpectedError: '[[#{multiTool.decrypt.unexpectedError}]]', + serverError: '[[#{multiTool.decrypt.serverError}]]', + success: '[[#{multiTool.decrypt.success}]]', };