Skip to content
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

Replace count prop from <Trans> in translation string automatically #826

Closed
manuelbieh opened this issue Apr 15, 2019 · 2 comments
Closed

Comments

@manuelbieh
Copy link

Is your feature request related to a problem? Please describe.
As already discussed on Twitter:
https://twitter.com/ManuelBieh/status/1117491118223106048

The current usage of the Trans component:

<Trans i18nKey="messageCount" count={3}>
  You have <strong>{{count: 3}}</strong> new messages.
</Trans>

with translation keys being:

messageCount: "Du hast <1>{{count}}</1> neue Nachricht",
messageCount_plural: "Du hast <1>{{count}}</1> neue Nachrichten",

feels unnecessarily complicated and also redundant if you're not using a variable for count. The value for count can possibly be replaced automatically based on the value that is passed to the count prop in the Trans component, so that this would be possible:

<Trans i18nKey="messageCount" count={3}>
  You have <strong>?</strong> new messages.
</Trans>

Describe the solution you'd like
I'd love to see this working:
https://codesandbox.io/s/oqj2o017w9

@jamuhl
Copy link
Member

jamuhl commented Apr 16, 2019

works in [email protected]

@manuelbieh
Copy link
Author

Schneller als die Feuerwehr 🚒 👨‍🚒 . Nice! Thank you!

@jamuhl jamuhl closed this as completed Apr 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants