【发布时间】:2017-02-11 16:18:10
【问题描述】:
我在一个项目中使用i18next,无法在翻译文件中包含html标签并正确呈现它们。
我的.json翻译文件示例:
"en": {
"product": {
"header": "Welcome, <strong>User!</strong>"
}
}
有一个excellent answer to this question,但与JQuery 有关。我没有使用 JQuery,我的项目是 React,这是我的设置:
import i18next from 'i18next';
import en from 'locales/en';
i18next.
init({
lng: 'en',
fallbackLng: false,
resources: en,
debug: false,
interpolation: {
escapeValue: false
}
});
export default i18next.t.bind(i18next);
在我的组件中:
import t from 'i18n';
t('product.header')
我想要的HTML:
Welcome, <strong>User!</strong>
我得到的 HTML:
Welcome, <strong>User!</strong>
谢谢
【问题讨论】:
-
您解决了这个问题吗?
-
@Petr Gaxarov - 如果你找到了,请分享解决方案。
标签: javascript html reactjs internationalization i18next