i18next: hebrew support for `something_plural` got broken

after pr #1121 (which is abviously great 😄 thank you @LeonardDrs!)

hebrew support for something_plural got broken.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 23 (11 by maintainers)

Most upvoted comments

  const i18n = i18next.createInstance().use(intervalPlural);

  18n.init({
    ...
  });

  const origGetSuffix = i18n.services.pluralResolver.getSuffix;
  i18n.services.pluralResolver.getSuffix = (code, count, ...other) => {
    if (code === 'he') {
      if (count > 1) {
        return '_plural';
      }
      return '';
    }
    return origGetSuffix.call(i18n.services.pluralResolver, code, count, ...other);
  };

by the way, for those who are interested, I end up using the following code:

      const origGetSuffix = i18next.services.pluralResolver.getSuffix;
      i18next.services.pluralResolver.getSuffix = (code, count, ...other) => {
        if (code === 'he') {
          if (count > 1) {
            return '_plural';
          }
          return '';
        }
        return origGetSuffix.call(i18next.services.pluralResolver, code, count, ...other);
      };

@LeonardDrs no need to take this on you…let’s say we both missed it -> but thanks to @vzaidman we could react and revert the mistake…

too bad i can’t star 5 times 😛

apply that to chinese or russian…just not the right thing

i’d link to https://www.i18next.com/translation-function/plurals in the migration guide as well

@0xR https://www.i18next.com/misc/migration-guide#v-11-x-x-to-v-12-0-0

And don’t forget to star this repo. Make a tweet or have a look at our https://locize.com -> there are many ways to help this project 🙏

if not happy with that you might provide some more details on how you would implement this or better a PR to review.

if requested by more people i would say yes - but in current state?!?

you can solve this in userland by overriding i18next.services.pluralResolver.getSuffix https://github.com/i18next/i18next/blob/master/src/PluralResolver.js#L119