如何解决ReactI18 在运行时检测 json 翻译的变化
我正在将 reacti18 集成到我的 nextjs 应用程序中,到目前为止它运行良好。语言环境保存在公共文件夹中,因此我希望如果我在运行时对任何 json 文件进行更改,那么应该立即在应用程序中检测到更改并且它应该呈现,但它目前没有检测到任何更改。>
这是我的 i18n 文件
import i18n from 'i18next';
import LanguageDetector from 'i18next-browser-languagedetector';
import Backend from 'i18next-http-backend';
import { initReactI18next } from 'react-i18next';
void i18n
// load translation using http -> see /public/locales (i.e. https://github.com/i18next/react-i18next/tree/master/example/react/public/locales)
// learn more: https://github.com/i18next/i18next-http-backend
.use(Backend)
// detect user language
// learn more: https://github.com/i18next/i18next-browser-languageDetector
.use(LanguageDetector)
// pass the i18n instance to react-i18next.
.use(initReactI18next)
// init i18next
// for all options read: https://www.i18next.com/overview/configuration-options
.init({
fallbackLng: 'en',interpolation: {
escapeValue: false,// not needed for react as it escapes by default
},react: {
useSuspense: false,// <---- this will do the magic
},});
export default i18n;
语言检测器负责在运行时检测文件,但不会检测应用程序运行时在任何 json 文件中所做的更改
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。