【问题标题】:React-i18n showing json property labels before rendering the translationReact-i18n 在渲染翻译之前显示 json 属性标签
【发布时间】:2021-04-21 19:55:43
【问题描述】:

我正在尝试将 react-i18n 添加到我的 React 应用程序中 - 在浏览器中进行缓存。 一切都很好,我已经添加了它 - 它有效。问题是,在我访问网站/应用程序的那一刻,大约 0.2 秒我可以看到翻译 json 中的所有属性标签(位于公共/语言环境中)。关于如何让网站“等待”属性被提取到他们的翻译中的任何想法 - 或者如何解决这个问题? 我在这里附上了 i18n 的配置文件和有问题的图像。请记住,这是 0.2 秒 - 之后一切正常(直到再次刷新页面 0.2 秒我可以看到标签)

谢谢!

配置文件:

import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import ChainedBackend from "i18next-chained-backend";
import HttpBackend from "i18next-http-backend";
import LocalStorageBackend from "i18next-localstorage-backend";
import LanguageDetector from 'i18next-browser-languagedetector';

i18n
  .use(ChainedBackend)
  .use(LanguageDetector)
  .use(initReactI18next)
  .init({
    fallbackLng: 'en',
    react: {
      useSuspense: false,
      wait: false,
    },
    backend: {
      backends: [
        LocalStorageBackend,
        HttpBackend
      ],
      backendOptions: [{
        expirationTime: 7 * 24 * 60 * 60 * 1000 // 7 days
      },
      {
        loadPath: '/locales/{{lng}}/translation.json'
      }]
    },
  });

export default i18n;

有问题的图片(时间很短):

【问题讨论】:

    标签: javascript reactjs internationalization translation


    【解决方案1】:

    【讨论】:

      猜你喜欢
      • 2018-11-03
      • 2017-02-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-15
      • 1970-01-01
      • 1970-01-01
      • 2019-10-14
      相关资源
      最近更新 更多