From 17faf095e9e7aead575b873050bbbe633aa70ee3 Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Tue, 9 Nov 2021 15:44:35 +0100 Subject: [PATCH] Update getLabel with locale option --- src/style_manager/model/Property.js | 9 +++++++-- src/style_manager/view/PropertyView.js | 6 +++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/style_manager/model/Property.js b/src/style_manager/model/Property.js index ed66704e3..9ade14085 100644 --- a/src/style_manager/model/Property.js +++ b/src/style_manager/model/Property.js @@ -67,10 +67,15 @@ export default class Property extends Model { /** * Get property label. + * @param {Object} [opts={}] Options + * @param {Boolean} [opts.locale=true] Use the locale string from i18n module * @returns {String} */ - getLabel() { - return this.get('name'); + getLabel(opts = {}) { + const { locale = true } = opts; + const id = this.getId(); + const name = this.get('name'); + return (locale && this.em?.t(`styleManager.properties.${id}`)) || name; } /** diff --git a/src/style_manager/view/PropertyView.js b/src/style_manager/view/PropertyView.js index 560d97bcd..0a0f20be9 100644 --- a/src/style_manager/view/PropertyView.js +++ b/src/style_manager/view/PropertyView.js @@ -16,10 +16,10 @@ export default Backbone.View.extend({ }, templateLabel(model) { - const { pfx, em } = this; + const { pfx } = this; const { parent } = model; - const { icon = '', info = '', id, name } = model.attributes; - const label = (em && em.t(`styleManager.properties.${id}`)) || name; + const { icon = '', info = '' } = model.attributes; + const label = model.getLabel(); return `