如何更改默认值react-i18next(在本地存储中)

Mar*_*002 5 typescript reactjs react-i18next

我正在使用后端和语言检测器,但是:

在 localstorage 中写入I18nextLng ,值为en-US,如何使默认值为I18nextLng,值为En

init和其他设置 - 默认文档

.init({
    fallbackLng: 'en',
    debug: true,
    interpolation: {
        escapeValue: false,
    },
})
Run Code Online (Sandbox Code Playgroud)

Vic*_*nte 3

我从来没有使用过语言检测器,但是我设置默认语言的方式是设置lng键,并且有资源obj

const resources = {
  en: { translation: {...} },
  fr: { translation: {...} }
}

.init({
    resources,
    lng: 'fr' // this is the default language. Try to put this
    fallbackLng: 'en',
    debug: true,
    interpolation: {
        escapeValue: false,
    },
})
Run Code Online (Sandbox Code Playgroud)