question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Better Document Trans Component

See original GitHub issue

Right 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:closed
  • Created 6 years ago
  • Reactions:10
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

5reactions
yoagauthiercommented, Jul 28, 2017

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 ?

4reactions
jeremybolescommented, Jul 22, 2017

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found