【发布时间】:2018-07-11 22:22:20
【问题描述】:
我的项目与 i18next 库配合良好。这是我的文件工作:
i18n/index.js
import i18n from 'i18next';
// import LanguageDetector from 'i18next-browser-languagedetector';
import pt from './locales/pt/common.json';
import en from './locales/en/common.json';
const options = {
interpolation: { escapeValue: false },
lng: 'en',
resources: {
pt: {
common: pt,
},
en: {
common: en,
},
},
fallbackLng: 'pt',
ns: ['common'],
defaultNS: 'common',
react: {
wait: true,
},
};
i18n.init(options);
export default i18n;
i18n/locales/en/common.json
"editor": {
"sidebar": {
"header": {
...
}
}
}
i18n/locales/pt/common.json
"editor": {
"sidebar": {
"header": {
...
}
}
}
但是,我需要在我的 json 文件前面加上 en 和 pt-BR。这样,我的项目停止工作。有人有简单的解决方案吗?
i18n/locales/en/common.json
"en" {
"editor": {
"sidebar": {
"header": {
...
}
}
}
}
i18n/locales/pt/common.json
"pt-BR" {
"editor": {
"sidebar": {
"header": {
...
}
}
}
}
【问题讨论】:
标签: i18next