Allow inserting react elements as arguments to translate
See original GitHub issueIt would be amazing if I could inject components into a string.
Let’s suppose I have this translation
{
"greeting": "<div>Welcome ${user}!</div>"
}
I’d like to be able to do this:
translate('greeting', { user: (
<strong>Jon Doe</strong>
)});
The result would be:
<div>Welcome <strong>Jon Doe</strong>!</div>
This is just a simple sample which can actually already be accomplished. However, I’m interested in being able to attach click listeners to components and then inject them into the translation.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:10 (4 by maintainers)
Top Results From Across the Web
JSX In Depth - React
The first part of a JSX tag determines the type of the React element. Capitalized types indicate that the JSX tag is referring...
Read more >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 render component inside a JSX argument
The problem is that component has not returned - executed when I insert it into the <input /> , that means that my...
Read more >How to translate your React app with react-i18next
You learn how to you can translate your React app with react-i18next. The tutorial also explains how to manage the translations json files...
Read more >How to Add Localization (l10n) to Your React App with react ...
The Nav.js file is the first component to translate. It's a functional component, so you can use the useTranslation hook. Import it at...
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
Just wanted to say it’s exciting to see the potential for this feature!
Added in #100 and published in
v3.2.0
. Thanks for the create work on this one @thchia.