From edbc1164d19f3da54bcd6ccf3b7913de5707666c Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Sat, 21 May 2016 20:25:32 +0930 Subject: [PATCH] Automatically support basic HTML tags in translations This allows front-end translations to use basic (attributeless) HTML tags freely, without the need for the translator call to supply a matching vdom element. Translations can thus make use of styling (, , etc.) as they see fit. The translator call can still optionally supply a vdom element to substitute in more complex tags where necessary (e.g. hyperlinks). /cc @dcsjapan --- framework/core/js/admin/dist/app.js | 4 ++-- framework/core/js/admin/src/components/EditGroupModal.js | 2 +- framework/core/js/forum/dist/app.js | 2 +- framework/core/js/lib/Translator.js | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/framework/core/js/admin/dist/app.js b/framework/core/js/admin/dist/app.js index e69fd5893..8b1773d2c 100644 --- a/framework/core/js/admin/dist/app.js +++ b/framework/core/js/admin/dist/app.js @@ -18368,7 +18368,7 @@ System.register('flarum/components/EditGroupModal', ['flarum/components/Modal', m( 'div', { className: 'helpText' }, - app.translator.trans('core.admin.edit_group.icon_text', { a: m('a', { href: 'http://fortawesome.github.io/Font-Awesome/icons/', tabindex: '-1' }) }, { em: m('em', null) }, { code: m('code', null) }) + app.translator.trans('core.admin.edit_group.icon_text', { a: m('a', { href: 'http://fortawesome.github.io/Font-Awesome/icons/', tabindex: '-1' }) }) ), m('input', { className: 'FormControl', placeholder: 'bolt', value: this.icon(), oninput: m.withAttr('value', this.icon) }) ), @@ -22146,7 +22146,7 @@ System.register('flarum/Translator', ['flarum/models/User', 'flarum/helpers/user if (match[2]) { open.shift(); } else { - var tag = input[match[3]] || []; + var tag = input[match[3]] || { tag: match[3], children: [] }; open[0].push(tag); open.unshift(tag.children || tag); } diff --git a/framework/core/js/admin/src/components/EditGroupModal.js b/framework/core/js/admin/src/components/EditGroupModal.js index cea3bfd92..f25e77612 100644 --- a/framework/core/js/admin/src/components/EditGroupModal.js +++ b/framework/core/js/admin/src/components/EditGroupModal.js @@ -52,7 +52,7 @@ export default class EditGroupModal extends Modal {
- {app.translator.trans('core.admin.edit_group.icon_text', {a: }, {em: }, {code: })} + {app.translator.trans('core.admin.edit_group.icon_text', {a: })}
diff --git a/framework/core/js/forum/dist/app.js b/framework/core/js/forum/dist/app.js index 0ee42cab7..f43dc528d 100644 --- a/framework/core/js/forum/dist/app.js +++ b/framework/core/js/forum/dist/app.js @@ -29718,7 +29718,7 @@ System.register('flarum/Translator', ['flarum/models/User', 'flarum/helpers/user if (match[2]) { open.shift(); } else { - var tag = input[match[3]] || []; + var tag = input[match[3]] || { tag: match[3], children: [] }; open[0].push(tag); open.unshift(tag.children || tag); } diff --git a/framework/core/js/lib/Translator.js b/framework/core/js/lib/Translator.js index 1f665634a..2800fce8d 100644 --- a/framework/core/js/lib/Translator.js +++ b/framework/core/js/lib/Translator.js @@ -74,7 +74,7 @@ export default class Translator { if (match[2]) { open.shift(); } else { - let tag = input[match[3]] || []; + let tag = input[match[3]] || {tag: match[3], children: []}; open[0].push(tag); open.unshift(tag.children || tag); }