React i18next 单数和复数问题,总是返回复数值

问题描述 投票:0回答:0

我有一些与 i18next 混淆的情况。当我使用英语时,它完全正确。但是当我将语言更改为 zh 时,它总是返回复数值事件,该值是单数。

我尝试升级依赖项,更改配置,但仍然无法正常工作。

我在以下链接中提供了示例代码。

https://codesandbox.io/s/react-i18next-plurals-forked-jgulw6?file=/public/locales/zh/translation.json

配置

i18n
  .use(Backend)
  .use(initReactI18next)
  .init({
    ns: ["common"],
    defaultNS: "common",
    resources,
    fallbackNS: "en",
    supportedLngs: ["en", "zh"],
    interpolation: {
      escapeValue: false
    },
    react: {
      bindI18n: "loaded languageChanged"
    },
    returnEmptyString: false,
    nsSeparator: false
  });

export default i18n;

依赖版本:

i18next             21.3.1
intl-pluralrules    1.3.1
react               17.0.0
react-i18next.      11.12.0
next.js i18next react-i18next
© www.soinside.com 2019 - 2024. All rights reserved.