-
-
Notifications
You must be signed in to change notification settings - Fork 642
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
Better API for plurals, for better extraction #2180
Comments
defaultValue already supports defining plural forms: https://www.i18next.com/translation-function/essentials#overview-options |
example: <Trans
i18nKey="newMessages"
count={count}
tOptions={{
defaultValue_one: "You have a message.",
defaultValue_other: "You have {{count}} messages.",
}}
/> https://react.i18next.com/latest/trans-component#trans-props |
Ahhh - good catch. I had not noticed that. Personally, I think that API is kind of awkward, but happy to give it a go 👍 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
🚀 Feature Proposal
A new API for specifying plurals in code, with explicit default messages for all plural forms.
Motivation
Many people's i18n workflow is to write default phrases in UI code with explicit keys with
t()
/<Trans />
, and then extract them with i18next-parser.Plurals make this very awkward because there's no way to extract additional plural forms from source code, so you must write one form in code, run i18n-parser, then go edit the json messages file with the additional forms. It also means there's no single source of truth for phrases, as additional plural forms would only live in the json messages file.
Example
I can't really see a great API for supporting this with the React
<Trans />
.If accepted, I'm happy to work on this and contribute it to i18next, and the required changes to i18next-parser.
See also i18next/i18next-parser#998
The text was updated successfully, but these errors were encountered: