Allow named components in Trans
See original GitHub issueThe documentation of Trans
has the following example:
<Trans id="Read the <0>docs</0>." components={{0: <a href="/docs" />}} />
Since the number tags don’t provide much context to the translator I was hoping I could use named tags instead as such:
<Trans id="Read the <link>docs</link>." components={{link: <a href="/docs" />}} />
Unfortunately, it seems only numbered tags are supported.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Trans Component - react-i18next documentation
This component enables you to nest any React content to be translated as one cohesive string. It supports both plural and interpolation. Let's...
Read more >React-i18n Trans Component with translations that contain ...
I read in the docs that you can use something called Trans components for translations with HTML tags. Docs: Using for <br />...
Read more >Use i18next Trans Component to Translate Complex React ...
The react-i18next library has a Trans component that we can use to interpolate or translate complex react element. In most cases, we don't...
Read more >Support passing objects to <Trans components={{ ... }} /> #833
Which would enable the use of the "named placeholder" method above. I can have a stab at this myself, just will have to...
Read more >Complex Translations Using the Trans Component
Let's assume that we want to use a Link component inside of our translations. The code might resemble this: <p> <label> <input type="checkbox"...
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 FreeTop 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
Top GitHub Comments
I’m replying (again again) to keep this issue from going stale. I would still very much like to see this implemented.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.