From 0cf788039156506b43584cdc69b0a7a59658a4e1 Mon Sep 17 00:00:00 2001 From: Antoine Beaubien Date: Sun, 21 Jun 2020 02:26:00 -0400 Subject: [PATCH] (I #2765) Fix i18n not working in the Edit Pref Window (#2766) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix i18n not working in the Edit Pref Window Fix i18n not working in the Edit Pref Window, added an error message on failure. * réussie -> réussi. --- .../modules/core/langs/translation-en.json | 1 + .../modules/core/langs/translation-fr.json | 1 + .../modules/core/scripts/preferences.js | 31 ++++++++++++------- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/main/webapp/modules/core/langs/translation-en.json b/main/webapp/modules/core/langs/translation-en.json index 65ef0d289..6585f3d2c 100644 --- a/main/webapp/modules/core/langs/translation-en.json +++ b/main/webapp/modules/core/langs/translation-en.json @@ -14,6 +14,7 @@ "core-index/value": "Value", "core-index/add-pref": "Add preference", "core-index/pref-key": "Preference key value:", + "core-index/prefs-loading-failed": "Failed to load the preferences.", "core-index/edit": "Edit", "core-index/delete": "Delete", "core-index/new-proj-name": "New project name:", diff --git a/main/webapp/modules/core/langs/translation-fr.json b/main/webapp/modules/core/langs/translation-fr.json index a9e49e677..d15135d2d 100644 --- a/main/webapp/modules/core/langs/translation-fr.json +++ b/main/webapp/modules/core/langs/translation-fr.json @@ -13,6 +13,7 @@ "core-index/version": "Version", "core-index/error-rename": "Échec du renommage du projet :", "core-index/pref-key": "Valeur de la préférence :", + "core-index/prefs-loading-failed": "La lecture des préférences n’a pas réussi.", "core-index/change-metadata-value": "Changer la valeur de la clé de métadonnée", "core-index/sample-data": "jeux de données d'exemple", "core-index/description": "Description :", diff --git a/main/webapp/modules/core/scripts/preferences.js b/main/webapp/modules/core/scripts/preferences.js index 36d7afcc2..81cf9c5b4 100644 --- a/main/webapp/modules/core/scripts/preferences.js +++ b/main/webapp/modules/core/scripts/preferences.js @@ -71,19 +71,28 @@ Refine.postCSRF = function(url, data, success, dataType, failCallback) { var lang = (navigator.language|| navigator.userLanguage).split("-")[0]; var dictionary = ""; $.ajax({ -url : "command/core/load-language?", -type : "POST", -async : false, -data : { -module : "core", -//lang : lang -}, -success : function(data) { -dictionary = data['dictionary']; -lang = data['lang']; -} + url : "command/core/load-language?", + type : "POST", + async : false, + data : { + module : "core", + //lang : lang + }, + success : function(data) { + dictionary = data['dictionary']; + lang = data['lang']; + } +}).fail(function( jqXhr, textStatus, errorThrown ) { + var errorMessage = $.i18n('core-index/prefs-loading-failed'); + if(errorMessage != "" && errorMessage != 'core-index/prefs-loading-failed') { + alert(errorMessage); + } else { + alert( textStatus + ':' + errorThrown ); + } }); + $.i18n().load(dictionary, lang); +$.i18n().locale = lang; //End internationalization function deDupUserMetaData(arrObj) {