【问题标题】:i18next::pluralResolver: Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfilli18next::pluralResolver:您的环境似乎与 Intl API 不兼容,请使用 Intl.PluralRules polyfill
【发布时间】:2022-01-26 07:38:47
【问题描述】:

请帮帮我。

错误 -

i18next::pluralResolver:您的环境似乎与 Intl API 不兼容,请使用 Intl.PluralRules polyfill。将回退到兼容JSON v3 格式处理

代码 -

    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;

【问题讨论】:

    标签: react-native i18next


    【解决方案1】:

    看起来像是 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'”添加到初始化“i18next”并解决错误:)
    • 谢谢 :) :) :)
    • 不客气!
    【解决方案2】:

    我遇到了同样的问题,使用 compatibilityJSON V3 模式意味着这在我的 IOS 模拟器上崩溃了,因为我实际上使用复数形式并且我使用的是 i18n-next的最新版本 (v21) >

    就我而言,我可以通过填充 intl-pluralrules 来修复它

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

    安装

    npm install intl-pluralrules
    

    Polyfill

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

    import 'intl-pluralrules'
    

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-04-05
      • 1970-01-01
      • 2021-09-07
      • 1970-01-01
      • 2013-04-15
      • 1970-01-01
      • 2012-04-20
      相关资源
      最近更新 更多