'How to declare custom Pluralization Rules vue-i18n Vue 3?

I have a rule for pluralization from https://kazupon.github.io/vue-i18n/guide/pluralization.html#accessing-the-number-via-the-pre-defined-argument But declaring it in the form

setup() {
    const { t, locale } = useI18n({
      pluralizationRules: {
        ru: function (choice, choicesLength) {
          if (choice === 0) {
            return 0;
          }

          const teen = choice > 10 && choice < 20;
          const endsWithOne = choice % 10 === 1;

          if (choicesLength < 4) {
            return !teen && endsWithOne ? 1 : 2;
          }
          if (!teen && endsWithOne) {
            return 1;
          }
          if (!teen && choice % 10 >= 2 && choice % 10 <= 4) {
            return 2;
          }

          return choicesLength < 4 ? 2 : 3;
        },
      },
    });
    return { t, locale };
  },

does not change anything (that is, for 0 - секунд, 1 - секунда, and the rest is секунд)

  • how can I fix this

I need

...1 секунда

...2-...3-...4 секунды

...0-...5-...6-...7-...8-...9 секунд

<i18n>
{
  "en": {
    "seconds":"{count} seconds | {count} second | {count} seconds"
  },
  "ru":{
    "seconds":"{count} секунд | {count} секунда | {count} секунд"
  }
}
</i18n>


Solution 1:[1]

I've quickly looked into the sources of vue-i18n and noticed that there are both pluralRules and pluralizationRules with the same type. For me it worked using pluralRules instead of pluralizationRules.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sergey Potanin