我使用的一个项目i18next,不能得到解决,包括翻译文件的HTML标签,并让他们正确地呈现。HTML标签阵营
我.json
翻译文件的一个例子:
"en": {
"product": {
"header": "Welcome, <strong>User!</strong>"
}
}
有一个excellent answer to this question,但是与JQuery的。我没有使用JQuery,我的项目是反应,这里是我的设置:
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>
比KS
随着V4.4.0我们增加了一个新的组件,使之简单,包括反应的组分到您的翻译https://react.i18next.com/components/trans-component.html – jamuhl