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

Viewed 10086

Please help me.

Error -

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

Code -

    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;
3 Answers

Look like an issue on 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,
 }
});

It should resolve your issue. You might need to check this.

Have fun.

I've had the same issue, and using the compatibilityJSON V3 mode meant that this broke on my IOS emulators because I actually use pluralisation and am on the latest version (v21) of i18n-next

In my case I could fix it by polyfilling intl-pluralrules

Have a look at https://github.com/eemeli/intl-pluralrules & https://www.i18next.com/misc/migration-guide

Installation

npm install intl-pluralrules

Polyfill

To use as a polyfill, just import it to ensure that Intl.PluralRules is available in your environment:

import 'intl-pluralrules'

If Intl.PluralRules already exists, includes a selectRange() method, and supports multiple locales, the polyfill will not be loaded.

before edit my code my i18n.js file

    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;

Add this line

compatibilityJSON: 'v3',

Related