From 60394354dc89aad994c99ab3bcc3b1734a6bac65 Mon Sep 17 00:00:00 2001 From: Horilla Date: Wed, 13 Sep 2023 16:40:16 +0530 Subject: [PATCH] [UPDT]Update in transalation in delete modal --- static/index/index.js | 89 +++++++++++++++++++++++++++++++++---------- 1 file changed, 69 insertions(+), 20 deletions(-) diff --git a/static/index/index.js b/static/index/index.js index 4360b734c..c8b686b5b 100644 --- a/static/index/index.js +++ b/static/index/index.js @@ -1,29 +1,78 @@ +var confirmModal = { + ar: "تأكيد", + de: "Bestätigen", + es: "Confirmar", + en: "Confirm", + fr: "Confirmer", +}; + +var cancelModal = { + ar: "إلغاء", + de: "Abbrechen", + es: "Cancelar", + en: "Cancel", + fr: "Annuler", +}; + +function getCookie(name) { + let cookieValue = null; + if (document.cookie && document.cookie !== "") { + const cookies = document.cookie.split(";"); + for (let i = 0; i < cookies.length; i++) { + const cookie = cookies[i].trim(); + // Does this cookie string begin with the name we want? + if (cookie.substring(0, name.length + 1) === name + "=") { + cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); + break; + } + } + } + return cookieValue; +} + +function getCurrentLanguageCode(callback) { + $.ajax({ + type: "GET", + url: "/employee/get-language-code/", + success: function (response) { + var languageCode = response.language_code; + callback(languageCode); // Pass the language code to the callback + }, + }); +} + var originalConfirm = window.confirm; // Override the default confirm function with SweetAlert window.confirm = function(message) { var event = window.event || {}; event.preventDefault(); + var languageCode = null; + getCurrentLanguageCode(function (code) { + languageCode = code; + var confirm = confirmModal[languageCode]; + var cancel = cancelModal[languageCode]; // Add event listener to "Confirm" button - $("#confirmModalBody").html(message) - var submit = false; - Swal.fire({ - text: message, - icon: 'question', - showCancelButton: true, - confirmButtonColor: '#008000', - cancelButtonColor: '#d33', - confirmButtonText: 'Confirm', - cancelButtonText: 'Cancel', - }).then((result) => { - if (result.isConfirmed) { - if (event.target.tagName.toLowerCase() === 'form') { - event.target.submit(); + $("#confirmModalBody").html(message) + var submit = false; + Swal.fire({ + text: message, + icon: 'question', + showCancelButton: true, + confirmButtonColor: '#008000', + cancelButtonColor: '#d33', + confirmButtonText: confirm, + cancelButtonText: cancel, + }).then((result) => { + if (result.isConfirmed) { + if (event.target.tagName.toLowerCase() === 'form') { + event.target.submit(); + } + else if (event.target.tagName.toLowerCase() === 'a') { + window.location.href = event.target.href; + } + } + else { } - else if (event.target.tagName.toLowerCase() === 'a') { - window.location.href = event.target.href; - } - } - else { - } + }) }); };