【发布时间】:2018-04-20 04:49:53
【问题描述】:
您好,我在我的 Node JS 应用程序中使用 i18next。 以下是 i18next 的配置代码:
const i18nextBackend = require('i18next-node-fs-backend');
i18n
.use(i18nextBackend)
.init({
fallbackLng: 'en',
debug: true,
backend: {
loadPath: 'locales/{{lng}}.json',
addPath: 'locales/{{lng}}.json',
jsonIndent: 2,
},
}, (err, t) => {
// init set content
console.log(t);
// console.log('INIT DONE');
});
console.log(i18n.t('hello'));
我的语言环境文件夹中有 en.js,其中有 JSON 格式的数据。但是文件无法加载。谁能告诉如何正确地在 loadPath 中给出路径名?
【问题讨论】:
标签: javascript node.js internationalization i18next