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 (<em>, <code>, 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
This commit is contained in:
Toby Zerner 2016-05-21 20:25:32 +09:30
parent 829f0e0275
commit edbc1164d1
4 changed files with 5 additions and 5 deletions

View File

@ -18368,7 +18368,7 @@ System.register('flarum/components/EditGroupModal', ['flarum/components/Modal',
m( m(
'div', 'div',
{ className: 'helpText' }, { 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) }) 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]) { if (match[2]) {
open.shift(); open.shift();
} else { } else {
var tag = input[match[3]] || []; var tag = input[match[3]] || { tag: match[3], children: [] };
open[0].push(tag); open[0].push(tag);
open.unshift(tag.children || tag); open.unshift(tag.children || tag);
} }

View File

@ -52,7 +52,7 @@ export default class EditGroupModal extends Modal {
<div className="Form-group"> <div className="Form-group">
<label>{app.translator.trans('core.admin.edit_group.icon_label')}</label> <label>{app.translator.trans('core.admin.edit_group.icon_label')}</label>
<div className="helpText"> <div className="helpText">
{app.translator.trans('core.admin.edit_group.icon_text', {a: <a href="http://fortawesome.github.io/Font-Awesome/icons/" tabindex="-1"/>}, {em: <em/>}, {code: <code/>})} {app.translator.trans('core.admin.edit_group.icon_text', {a: <a href="http://fortawesome.github.io/Font-Awesome/icons/" tabindex="-1"/>})}
</div> </div>
<input className="FormControl" placeholder="bolt" value={this.icon()} oninput={m.withAttr('value', this.icon)}/> <input className="FormControl" placeholder="bolt" value={this.icon()} oninput={m.withAttr('value', this.icon)}/>
</div> </div>

View File

@ -29718,7 +29718,7 @@ System.register('flarum/Translator', ['flarum/models/User', 'flarum/helpers/user
if (match[2]) { if (match[2]) {
open.shift(); open.shift();
} else { } else {
var tag = input[match[3]] || []; var tag = input[match[3]] || { tag: match[3], children: [] };
open[0].push(tag); open[0].push(tag);
open.unshift(tag.children || tag); open.unshift(tag.children || tag);
} }

View File

@ -74,7 +74,7 @@ export default class Translator {
if (match[2]) { if (match[2]) {
open.shift(); open.shift();
} else { } else {
let tag = input[match[3]] || []; let tag = input[match[3]] || {tag: match[3], children: []};
open[0].push(tag); open[0].push(tag);
open.unshift(tag.children || tag); open.unshift(tag.children || tag);
} }