From dda1b4e547a154cf073eb2bdae1e346ccda983b6 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Sun, 3 Jul 2022 12:54:11 +0300 Subject: [PATCH] fix translate option --- client/src/view-helper.js | 4 ++++ client/src/views/fields/enum.js | 9 ++++++--- client/src/views/preferences/fields/theme.js | 14 +++++++------- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/client/src/view-helper.js b/client/src/view-helper.js index 259d9d7b14..f367beea3e 100644 --- a/client/src/view-helper.js +++ b/client/src/view-helper.js @@ -389,6 +389,10 @@ function (marked, DOMPurify, /** typeof Handlebars */Handlebars) { } } + if (name === null) { + name = ''; + } + return translationHash[name] || name; }); diff --git a/client/src/views/fields/enum.js b/client/src/views/fields/enum.js index 003195216c..dd55f340e2 100644 --- a/client/src/views/fields/enum.js +++ b/client/src/views/fields/enum.js @@ -79,11 +79,14 @@ function (Dep, Selectize, _) { } } + let translationKey = value || ''; + if ( - typeof value !== 'undefined' && value !== null && value !== '' + typeof value !== 'undefined' && value !== null && value !== '' || - value === '' && ( - value in (this.translatedOptions || {}) && (this.translatedOptions || {})[value] !== '' + translationKey === '' && ( + translationKey in (this.translatedOptions || {}) && + (this.translatedOptions || {})[translationKey] !== '' ) ) { data.isNotEmpty = true; diff --git a/client/src/views/preferences/fields/theme.js b/client/src/views/preferences/fields/theme.js index 2b00448de6..246f8e2f49 100644 --- a/client/src/views/preferences/fields/theme.js +++ b/client/src/views/preferences/fields/theme.js @@ -26,14 +26,15 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('views/preferences/fields/theme', 'views/fields/enum', function (Dep) { +define('views/preferences/fields/theme', ['views/fields/enum'], function (Dep) { return Dep.extend({ setup: function () { - this.params.options = Object.keys(this.getMetadata().get('themes')).sort(function (v1, v2) { - return this.translate(v1, 'themes').localeCompare(this.translate(v2, 'themes')); - }.bind(this)); + this.params.options = Object.keys(this.getMetadata().get('themes')) + .sort((v1, v2) => { + return this.translate(v1, 'themes').localeCompare(this.translate(v2, 'themes')); + }); this.params.options.unshift(''); @@ -41,11 +42,10 @@ Espo.define('views/preferences/fields/theme', 'views/fields/enum', function (Dep this.translatedOptions = this.translatedOptions || {}; - var defaultTranslated = this.translatedOptions[this.getConfig().get('theme')] || this.getConfig().get('theme'); + var defaultTranslated = this.translatedOptions[this.getConfig().get('theme')] || + this.getConfig().get('theme'); this.translatedOptions[''] = this.translate('Default') + ' (' + defaultTranslated + ')'; }, - }); - });