i18next::pluralResolver:您的环境似乎与 Intl API 不兼容,请使用 Intl.PluralRules polyfill

i18next::pluralResolver: Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill

请帮帮我

错误-

i18next::pluralResolver: Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling

代码-

    import i18n from "i18next";
    import english from './englist.json';
    import thai from './thai.json';
    import { initReactI18next } from "react-i18next";
    i18n.use(initReactI18next).init({
        lng:'th',
        fallbackLng: 'en',
        resources:{
            en:english,
            th:thai
        },
        interpolation: {
            escapeValue: false 
        },
        react:{
            useSuspense:false,
        }
    });
    export default i18n;

看起来像是 android 上的问题。

i18n.use(initReactI18next).init({
  compatibilityJSON: 'v3', <--- add this line.
  lng:'th',
  fallbackLng: 'en',
  resources:{
    en:english,
    th:thai
  },
  interpolation: {
    escapeValue: false 
  },
  react: {
    useSuspense:false,
 }
});

它应该可以解决您的问题。您可能需要检查 this.

玩得开心。

我遇到了同样的问题,使用 compatibilityJSON V3 模式意味着这会破坏我的 IOS 模拟器,因为我实际上使用了复数形式并且我使用的是 i18n-下一个

在我的例子中,我可以通过 polyfilling 来修复它 intl-pluralrules

看看https://github.com/eemeli/intl-pluralrules & https://www.i18next.com/misc/migration-guide

安装

npm install intl-pluralrules

填充

要用作 polyfill,只需导入它以确保 Intl.PluralRules 是 在您的环境中可用:

import 'intl-pluralrules'

如果Intl.PluralRules已经存在, 包括一个 selectRange() 方法, 并支持 multiple locales, 将不会加载 polyfill。

在编辑我的代码之前 我的i18n.js文件

    import i18n from 'i18next';
import {initReactI18next} from 'react-i18next';
import en from '../Language/en.json';
import hi from '../Language/hi.json';

i18n.use(initReactI18next).init({
lng: 'en',
fallbackLng: 'en',
resources: {
    en: en,
    hi: hi,
},
interpolation: {
    escapeValue: false
}
});

export default i18n;

添加这一行

兼容性 JSON:'v3',