From 56cfe58c0a9fb879580afd2349dc5bc9c0a0d67b Mon Sep 17 00:00:00 2001 From: Dmitry Khomutov Date: Sat, 14 Jan 2017 16:58:55 +0700 Subject: [PATCH] Added localization for delete confirmation dialog --- public/assets/js/app.js | 20 +++++++++++--------- src/PHPCensor/Languages/lang.en.php | 7 +++++++ src/PHPCensor/Languages/lang.ru.php | 7 +++++++ src/PHPCensor/View/Build/view.phtml | 5 ++--- src/PHPCensor/View/BuildsTable.phtml | 3 ++- src/PHPCensor/View/Group/index.phtml | 2 +- src/PHPCensor/View/Project/view.phtml | 5 ++--- src/PHPCensor/View/User/index.phtml | 3 ++- 8 files changed, 34 insertions(+), 18 deletions(-) diff --git a/public/assets/js/app.js b/public/assets/js/app.js index 1e87c5a8..143a3ba5 100644 --- a/public/assets/js/app.js +++ b/public/assets/js/app.js @@ -164,11 +164,13 @@ if (!Function.prototype.bind) { /** * Used for delete buttons in the system, just to prevent accidental clicks. */ -function confirmDelete(url, subject, reloadAfter) { +function confirmDelete(url, reloadAfter) { var dialog = new PHPCensorConfirmDialog({ - message: subject + ' will be permanently deleted. Are you sure?', - confirmBtnCaption: 'Delete', + title: Lang.get('confirm_title'), + message: Lang.get('confirm_message'), + confirmBtnCaption: Lang.get('confirm_ok'), + cancelBtnCaption: Lang.get('confirm_cancel'), /* confirm-btn click handler */ @@ -188,10 +190,10 @@ function confirmDelete(url, subject, reloadAfter) { }; } - dialog.showStatusMessage('Successfully deleted!', 500); + dialog.showStatusMessage(Lang.get('confirm_success'), 500); }, error: function (data) { - dialog.showStatusMessage('Deletion failed! Server says "' + data.statusText + '"'); + dialog.showStatusMessage(Lang.get('confirm_failed') + data.statusText); if (data.status == 401) { handleFailedAjax(data); @@ -210,8 +212,8 @@ function confirmDelete(url, subject, reloadAfter) { * @type {{message: string, title: string, confirmBtnCaption: string, cancelBtnCaption: string, confirmed: Function}} */ var PHPCensorConfirmDialogOptions = { - message: 'The action will be performed and cannot be undone. Are you sure?', - title: 'Confirmation Dialog', + message: 'Are you sure?', + title: 'Confirmation', confirmBtnCaption: 'Ok', cancelBtnCaption: 'Cancel', confirmed: function (e) { @@ -350,7 +352,7 @@ var PHPCensorConfirmDialog = Class.extend({ showStatusMessage: function (message, closeTimeout) { this.$confirmBtn.hide(); - this.$cancelBtn.html('Close'); + this.$cancelBtn.hide(); /* Status message @@ -468,7 +470,7 @@ var Lang = { return sprintf.apply(sprintf[0], args); } - return 'MISSING: ' + string; + return string; } }; diff --git a/src/PHPCensor/Languages/lang.en.php b/src/PHPCensor/Languages/lang.en.php index 83353402..2f4e99b6 100644 --- a/src/PHPCensor/Languages/lang.en.php +++ b/src/PHPCensor/Languages/lang.en.php @@ -490,4 +490,11 @@ PHP Censor', 'slack_notify' => 'Slack', 'technical_debt' => 'Technical Debt', 'xmpp' => 'XMPP', + + 'confirm_message' => 'Item will be permanently deleted. Are you sure?', + 'confirm_title' => 'Item delete confirmation', + 'confirm_ok' => 'Delete', + 'confirm_cancel' => 'Cancel', + 'confirm_success' => 'Item successfully deleted.', + 'confirm_failed' => 'Deletion failed! Server says: ', ]; diff --git a/src/PHPCensor/Languages/lang.ru.php b/src/PHPCensor/Languages/lang.ru.php index faa01b83..f073555f 100644 --- a/src/PHPCensor/Languages/lang.ru.php +++ b/src/PHPCensor/Languages/lang.ru.php @@ -474,4 +474,11 @@ PHP Censor', 'slack_notify' => 'Slack', 'technical_debt' => 'Technical Debt', 'xmpp' => 'XMPP', + + 'confirm_message' => 'Элемент будет удален навсегда. Вы уверены?', + 'confirm_title' => 'Подтвержение удаления', + 'confirm_ok' => 'Удалить', + 'confirm_cancel' => 'Отмена', + 'confirm_success' => 'Элемент успешно удален.', + 'confirm_failed' => 'Удаление провалилось! Ответ сервера: ', ]; diff --git a/src/PHPCensor/View/Build/view.phtml b/src/PHPCensor/View/Build/view.phtml index 3deb188a..ae311f2f 100644 --- a/src/PHPCensor/View/Build/view.phtml +++ b/src/PHPCensor/View/Build/view.phtml @@ -180,9 +180,8 @@ foreach ($plugins as $plugin) { $('#delete-build').on('click', function (e) { e.preventDefault(); - confirmDelete( - "build/delete/getId(); ?>", "Build" - ).onCloseConfirmed = function () {window.location = 'project/view/getProjectId(); ?>'}; + confirmDelete("build/delete/getId(); ?>") + .onCloseConfirmed = function () {window.location = 'project/view/getProjectId(); ?>'}; }); }); diff --git a/src/PHPCensor/View/BuildsTable.phtml b/src/PHPCensor/View/BuildsTable.phtml index d99f083c..edaf5c7c 100644 --- a/src/PHPCensor/View/BuildsTable.phtml +++ b/src/PHPCensor/View/BuildsTable.phtml @@ -90,7 +90,8 @@ switch($build->getStatus()) $(document).ready(function() { $('.delete-build').on('click', function (e) { e.preventDefault(); - confirmDelete(e.target.href, "Build").onCloseConfirmed = function () {window.location = window.location.href}; + confirmDelete(e.target.href) + .onCloseConfirmed = function () {window.location = window.location.href}; }); }); diff --git a/src/PHPCensor/View/Group/index.phtml b/src/PHPCensor/View/Group/index.phtml index 3ba0e08c..b9041ca4 100644 --- a/src/PHPCensor/View/Group/index.phtml +++ b/src/PHPCensor/View/Group/index.phtml @@ -42,7 +42,7 @@ $(document).ready(function() { $('.delete-group').on('click', function (e) { e.preventDefault(); - confirmDelete(e.target.href, "Group").onCloseConfirmed = function () {window.location = window.location.href}; + confirmDelete(e.target.href).onCloseConfirmed = function () {window.location = window.location.href}; }); }); \ No newline at end of file diff --git a/src/PHPCensor/View/Project/view.phtml b/src/PHPCensor/View/Project/view.phtml index e27a571d..54d7f697 100644 --- a/src/PHPCensor/View/Project/view.phtml +++ b/src/PHPCensor/View/Project/view.phtml @@ -164,9 +164,8 @@ print ''; $(function() { $('#delete-project').on('click', function (e) { e.preventDefault(); - confirmDelete( - "project/delete/getId(); ?>", "Project" - ).onCloseConfirmed = function () {window.location = '/'}; + confirmDelete("project/delete/getId(); ?>") + .onCloseConfirmed = function () {window.location = '/'}; }); }) diff --git a/src/PHPCensor/View/User/index.phtml b/src/PHPCensor/View/User/index.phtml index 20494a1f..c6675455 100644 --- a/src/PHPCensor/View/User/index.phtml +++ b/src/PHPCensor/View/User/index.phtml @@ -63,7 +63,8 @@ $(document).ready(function() { $('.delete-user').on('click', function (e) { e.preventDefault(); - confirmDelete(e.target.href, "User").onCloseConfirmed = function () {window.location = window.location.href}; + confirmDelete(e.target.href) + .onCloseConfirmed = function () {window.location = window.location.href}; }); });