0
我已经知道如何通过react-native-i18n生成i18n字符串。例如,将属性添加到React Native中的i18n字符串
// en.js source
{
"hello": "Hello, {{name}}."
}
// use
I18n.t("hello", { name: "John" })
,它显示Hello, John.
。
我也知道如何生成属性串:
<Text>
This is a <Text style={{fontWeight: 'bold'}}>bold<Text> word.
<Text>
,它显示This is a
bold
word
。
问题是,我如何添加属性到一个国际化的模板字符串?任何这个库?
// en.js source
{
"hello": "Hello, <b>{{guest}}</b>. I'm {{host}}."
}
// use
I18n.t("hello", { guest: "John", host: "Sam" })
- 预计:
Hello,
John
. I'm Sam.
- 什么我:
Hello, <b>John</b>. I'm Sam.