microapps / gatsby-plugin-react-i18next

Easily translate your Gatsby website into multiple languages
MIT License
121 stars 72 forks source link

How to handle plurals? #130

Open M4ss1ck opened 2 years ago

M4ss1ck commented 2 years ago

There's nothing on this repo about how to handle plurals, only a little note about nested translation keys.

I tried as in react-i18next docs

const messages = ['message one', 'message two'];

<Trans i18nKey="newMessages" count={messages.length}>
  You got {{ count: messages.length }} messages.
</Trans>

// Translation strings:
// "newMessages": "You got one message."
// "newMessages_plural": "You got {{count}} messages."

Is there any workaround or this is not possible?

thibaultcrouzet commented 2 years ago

Hey @M4ss1ck , did you give a try ?

"newMessages_one": "You got one message.", "newMessages_other": "You got {{count}} messages."

Or

"newMessagesWithCount_one": "You got one message.", "newMessagesWithCount_other": "You got {{count}} messages."