I am displaying internationalized strings within a Polymer element as follows:
<div>
<span class="title">{{title}}</span>
<br/><br/>
<span class="subtitle">{{subtitle1}}</span>
<br/>
<span class="content">{{paragraph1}}</span>
<br/><br/>
<span class="subtitle">{{subtitle2}}</span>
<br/>
<span class="content">{{paragraph2}}</span>
</div>
... and have the following dart code:
@observable String title;
@observable String subtitle1;
@observable String paragraph1;
@observable String subtitle2;
@observable String paragraph2;
//...
void onUpdateLocale(_locale) {
title = getTitle();
subtitle1 = getSubtitle1();
paragraph1 = getParagraph1();
subtitle2 = getSubtitle2();
paragraph2 = getParagraph2();
}
//...
getTitle() => Intl.message('MY TITLE', name:'title',
desc: 'This is my title',
args: [],
examples: {'None' : 0});
getSubtitle1() => Intl.message('Subtitle 1', name:'subtitle1',
desc: 'This is my first subtitle',
args: [],
examples: {'None' : 0});
getParagraph1() => Intl.message('This is my first paragraph',
name:'paragraph1',
desc: 'This is the my first paragraph',
args: [],
examples: {'None' : 0});
getSubtitle2() => Intl.message('Subtitle 2', name:'subtitle1',
desc: 'This is my second subtitle',
args: [],
examples: {'None' : 0});
getParagraph2() => Intl.message('This is my second paragraph',
name:'paragraph2',
desc: 'This is the my second paragraph',
args: [],
examples: {'None' : 0});
Is there a way to combine title
, subtitle1
, paragraph1
, subtitle2
, and paragraph2
into one observable variable that includes the <br>
and <span>
tags in its value?
Update
A ready-to-use element for Dart Polymer 1.0 is bwu-bind-html
Update
Polymer now provides support for this out of the box
Old
This is the code of the
<safe-html>
tag I'm using.usage: