Nested HTML element within Trans seems like not working
See original GitHub issueDescribe the bug Nested HTML element within Trans seems like not working
Occurs in react-i18next version 10.11.3
To Reproduce Steps to reproduce the behavior:
i have this
<Trans i18nKey={"Are you sure you want to <0>delete</0> account <0><1>{{name}}</1></0> ?"} values={{name}} components={[<b key={0} />, <i key={1} />]} >
</Trans>
{{name}} should be bold then italic, however, it becomes simply not shown.
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (7 by maintainers)
Top Results From Across the Web
Problems when parsing nested html tags from string
It sounds like you want a recursive function that prints the textContent of itself, or of its children, if it has children:.
Read more >Text in Nested Div Won't Style - HTML & CSS - SitePoint Forums
I've created a nested div and put some text into it with a h1 header assignation. I try and change the font family...
Read more >Template Language - SparkPost Developers
The SparkPost API provides a powerful handlebars-style template language that you can use in the email subject, headers, text, HTML, and AMP HTML...
Read more >Transforming XML Data with XSLT - Oracle Help Center
Here, you will create a simple test document using nested <SECT> elements, a few <PARA> elements, a <NOTE> element, a <LINK>, and a...
Read more >Using HTML's translate attribute - W3C
The translate attribute in HTML5 indicates that the content of the ... is no , translation tools should protect the text of the...
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
Oh, now I finally understand how the
components
prop works! For future readers reference, this is how I could have written my example above to get the expected results:But to be fair, this is a rather confusing API, that yields an awkward
components
prop declaration and hard to maintain translation texts like<0><0><0>this</0></0></0>
.I see there’s already some ongoing discussion at #833 to allow for named placeholders by passing an object to
components
prop, which would help a lot.In my opinion, making the numbered placeholders match the equivalent position in the
components
array would be a more intuitive API than having to track nesting levels.But more importantly, how to use
<Trans>
with nested components should definitely be in the documentation.