这是我的i18n文件的样子 -
import i18n from 'i18next'
import { initReactI18next } from 'react-i18next'
import HttpApi from 'i18next-http-backend';
i18n
.use(HttpApi)
.use(initReactI18next)
.init({
// resources: resourcesObj,
initImmediate: false,
backend: {
loadPath: 'https://bucketlink.amazonaws.com/locales/{{lng}}/{{ns}}.json',
crossDomain: true,
allowMultiLoading: true,
},
lng: "en",
fallbackLng: "en",
debug: false,
ns: ["translations"],
defaultNS: "translations",
keySeparator: false,
interpolation: {
escapeValue: true
}
});
export default i18n;
当我更改语言时,我在“网络”选项卡中看到 JSON 正确来自 S3。但是,在我的所有屏幕中都显示了键而不是值。有人可以让我知道为什么我的翻译值没有显示。
注意——如果我使用资源并将我的 json 对象放在其中,它会按预期工作。