I've already known how to generate i18n string through react-native-i18n. For example,
// en.js source
{
"hello": "Hello, {{name}}."
}
// use
I18n.t("hello", { name: "John" })
and it shows Hello, John.
.
I've also known how to generate attributed string:
<Text>
This is a <Text style={{fontWeight: 'bold'}}>bold<Text> word.
<Text>
and it shows This is a
bold
word
.
The problem is, how can I add attributes to a i18n template string? Any library for this?
// en.js source
{
"hello": "Hello, <b>{{guest}}</b>. I'm {{host}}."
}
// use
I18n.t("hello", { guest: "John", host: "Sam" })
- Expected:
Hello,
John
. I'm Sam.
- What I got:
Hello, <b>John</b>. I'm Sam.