diff --git a/src/core/i18n-wrapper.js b/src/core/i18n-wrapper.js index fba3152408..460b478378 100644 --- a/src/core/i18n-wrapper.js +++ b/src/core/i18n-wrapper.js @@ -12,14 +12,33 @@ import I18N from "./i18n"; // we're creating a singleton here so we can potentially // delay the initialization of the translate catalog // until after the dom is available -let _t = null; -const translate = function (msgid, keywords) { - if (_t === null) { +let _translation_domains = { + "plone": null, + "widgets": null, +}; + +const translate = function(domain, msgid, keywords) { + if(_translation_domains[domain] === null) { var i18n = new I18N(); - i18n.loadCatalog("widgets"); - _t = i18n.MessageFactory("widgets"); + i18n.loadCatalog(domain); + _translation_domains[domain] = i18n.MessageFactory(domain); } - return _t(msgid, keywords); + return _translation_domains[domain](msgid, keywords); +}; + +const translate_widgets = function(msgid, keywords) { + return translate("widgets", msgid, keywords); }; -export default translate; +const translate_plone = function(msgid, keywords) { + return translate("plone", msgid, keywords); +}; + +// backwards compatibilty: "widgets" domain is default factory +export default translate_widgets; + +// explicit export of translation domain factories +export { + translate_widgets, + translate_plone, +} diff --git a/src/pat/structure/js/views/table.js b/src/pat/structure/js/views/table.js index d85967ac2b..66a67364d8 100644 --- a/src/pat/structure/js/views/table.js +++ b/src/pat/structure/js/views/table.js @@ -48,6 +48,10 @@ export default BaseView.extend({ "end", "last_comment_date", ]; + + self.translatableColumns = [ + "review_state", + ]; }, events: { diff --git a/src/pat/structure/js/views/tablerow.js b/src/pat/structure/js/views/tablerow.js index a208481587..f96026870d 100644 --- a/src/pat/structure/js/views/tablerow.js +++ b/src/pat/structure/js/views/tablerow.js @@ -1,6 +1,7 @@ import $ from "jquery"; import _ from "underscore"; import _t from "../../../../core/i18n-wrapper"; +import { translate_plone as _tp } from "../../../../core/i18n-wrapper"; import utils from "../../../../core/utils"; import Backbone from "backbone"; @@ -109,6 +110,9 @@ export default Backbone.View.extend({ } return date.toLocaleString(this.app.language, this.app.dateFormat); } + if (this.table.translatableColumns.includes(column)) { + return _tp(value); + } return value; }, diff --git a/src/pat/structure/templates/tablerow.xml b/src/pat/structure/templates/tablerow.xml index 3c0c1e3054..2937c62ec4 100644 --- a/src/pat/structure/templates/tablerow.xml +++ b/src/pat/structure/templates/tablerow.xml @@ -40,7 +40,7 @@ <% _.each(activeColumns, (column) => { %> <% if(column !== 'Description' && _.has(availableColumns, column)) { %> -