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.

How do you handle dynamic translations?

See original GitHub issue

Hi,

Is it possible to translate the example below?

{routes.map(route => <Trans>{route}</Trans>)}

If routes equals [‘home’, ‘contact’] i’d expect two new keys to be extracted ‘home’ and ‘contact’. However, currently what is extracted is ‘{0}’.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
tricoder42commented, Mar 7, 2018

Exactly, @lingui/babel-plugin-extract-messages finds i18nMark function calls and extracts it and remove i18nMark function completely.

2reactions
tricoder42commented, Mar 7, 2018

Yeah, first you need to use i18nMark to mark translatable strings and then pass it as an id either to <Trans> component or i18n._ method:

const routes = [i18nMark('home'), i18nMark('contact')]

routes.map(route => <Trans id={route} />)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dynamic Translation - Product Documentation | ServiceNow
The Dynamic Translation spoke provides actions to enable the ability to translate multiple texts from one language into one or more languages ...
Read more >
Dynamic translation on forms and activity streams - YouTube
Explains how to enable a dictionary for translating forms and activity streams. This video applies to UI16, the latest version of the user ......
Read more >
How to translate dynamic content? - Help Center
In this article, you'll find how to translate dynamic content. 1) Head over to your site and right-click to pull up the menu...
Read more >
5 smart tips for localizing dynamic content - Smartcat
Use machine translation + post-editing. · Accumulate knowledge. · Work directly with freelancers. · Approach different content differently. · Let ...
Read more >
Translating Dynamic Content (Strings) - Phrase
Keep translations of dynamic content in a separate project, next to the project already in use for handling static translations. Depending on quantity...
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