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.

Allow inserting react elements as arguments to translate

See original GitHub issue

It 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:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
da1nerdcommented, Jun 12, 2018

Just wanted to say it’s exciting to see the potential for this feature!

0reactions
ryandrewjohnsoncommented, Jun 25, 2018

Added in #100 and published in v3.2.0. Thanks for the create work on this one @thchia.

Read more comments on GitHub >

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

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