Better Document Trans Component
See original GitHub issueRight now it is very unclear which index is needed to reference children and why sometimes nested interpolation-indexes are needed (<0><1>...</1></0>).
It is also not documented how interpolation using {{value}} works and how value names are resolved.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:10
- Comments:12 (8 by maintainers)
Top Results From Across the Web
Trans Component - react-i18next documentation
How to get the correct translation string? · 1. use React Developer Tools to inspect the <Trans> component instance and look at the...
Read more >Use i18next Trans Component to Translate Complex React ...
In this article, I will try to make more clear and easy to understand on how actually Trans Component is implemented to translate...
Read more >React-i18next trans component explained - Oscar Franco
While the Trans component gives you a lot of power by letting you interpolate or translate complex react elements - the truth is...
Read more >How to use the Trans component for bold or italicized text in ...
I am trying to use nested bold or italicized text in my JSON strings. For context, I have translation file called "homepage.json" which...
Read more >Developer's guide to internationalization
You can see available formattings in ./config/client/i18n.js . And you can add more there. For the translations containing html, you can use Trans...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

As a farly new user of react-i18next, I’m puzzeled about a few things that maybe the documentation should detail :
the un-natural look of my JSX code regarding to what’s outputed :
<Trans i18nKey="terms">I accept <Button> Terms & Conditions </Button></Trans>JSON :"terms": "I accept <1> Terms & Conditions </1>"and<Trans i18nKey="terms">I love <Button> Pizza </Button></Trans>JSON :"terms": "I accept <1> Terms & Conditions </1>"output the same things. You detailed the reasons in #271 but I think it’s not clear to a new user. What about suggesting a syntax in the docs like :<Trans i18nKey="termAcceptance">#<Button>#</Button></Trans>For me the syntax of the Interpolate component is clearer, but JSX does not allow to pass opening tags or closing tags alone as props.what’s the best workflow to produce my JSON with the interpolation indexes ? Set the Trans tag, then testing my app, then copy / pasting the generated output ? This, does not seems optimal, is there any way of guessing the generated output if I want to save time ?
It would great too to see some documentation on using the component with React Native too. Right now it is unclear of the component is even supported there.