【发布时间】:2021-10-04 16:44:13
【问题描述】:
我正在尝试在我的 React 应用程序中使用 i18next 和插值
这是 React 代码中的示例
{i18n.t('hours', {ns:'namespace', count: 100})}
<Trans i18nKey='hours' ns='namespace' count={10}/>
{t('hours', {count: 1})}
这是我的“namespace.json”
"hours_one": "час",
"hours_few": "часа",
"hours_many": "часов"
"hours": "часы {{count}}"
这是我的输出
часы 100
часы {{count}}
часы 1
如您所见,不起作用。我不知道为什么。 有人可以帮助我了解我做错了什么吗?
配置
const resources = {
ru: {
namespace: namespaceRU
}
};
i18n
.use(Backend)
.use(LanguageDetector)
.use(initReactI18next)
.init({
resources,
fallbackLng: 'ru',
debug: true,
supportedLngs: ['ru'],
interpolation: {
escapeValue: false, // not needed for react as it escapes by default
},
react: {
useSuspense: false
},
});
【问题讨论】:
标签: string-interpolation i18next