-
-
Notifications
You must be signed in to change notification settings - Fork 629
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plural with arrays #1196
Comments
It runs through all the items in the array or object -> https://github.com/i18next/i18next/blob/master/src/Translator.js#L131 (to assert those inner values in the object, array, get interpolated, postprocessed,...) which result in taking a possible fix might be changing https://github.com/i18next/i18next/blob/master/src/Translator.js#L133 setting resUsedKey to _plural (or correct suffix based on language and count) if is array and has count in options. While i agree this is an issue - i must say this is a rather edge case use case -> what's the idea behind using an array here instead of 2 keys? |
Thanks for the quick reply. We at @jovotech work on a framework for voice apps (Alexa Skills, Google Actions) were we integrated i18next (Thank you for the great library!!!) Example:
Usage in code let speech = this.speechBuilder().addT('WELCOME');
this.tell(speech); // Alexa says "Welcome", "Hey" or "Hello" This works perfectly fine! Would be cool if it worked with plural with arrays, too. |
Ok i see...seems to make sense. Currently i'm hard on time - so might take me a few days to get that in. If you feel confortable enough with the i18next codebase you might try a PR to speed this up...but not an easy one as needs to work for all pluralforms... |
Indeed, not an easy one :) I'm afraid I don't have an overview for such a task. There's no hurry. Thank you! |
could you try with [email protected] |
Works perfectly! Thank you! |
If you like this module don’t forget to star this repo. Make a tweet, share the word or have a look at our https://locize.com to support the devs of this project -> there are many ways to help this project 🙏 |
Hey!
I may misunderstand something, but I can't get plurals to work with arrays.
Steps to reproduce:
What I expect:
What I get:
Thanks in advance!
The text was updated successfully, but these errors were encountered: