Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

302
Views
How to render component as a param using i18n-js in react-native?

I am using i18n-js for locales and translations. I am trying to render a react-native component using interpolation.

Following is the code for reference,

// Translate function (exposed using custom hooks)
const translate = useCallback((key, config) => i18n.t(key, config), []);
// locale key with variables to be interpolated
"tnc_text": "Accept {{topUpTnC}} and {{dealsTnC}} to proceed"
// Code which uses translate
<Text>
  {translate(
    'tnc_text', {
      topUpTnC: <Text
        style={{color: 'blue'}}
        onPress={() => Linking.openURL('https://google.com')}>
        Top-Up Terms and Conditions*
      </Text>,
      dealsTnC: <Text
        style={{color: 'blue'}}
        onPress={() => Linking.openURL('https://example.com')}>
        Deals Terms and Conditions
      </Text>,
  })}
</Text>

I am expecting something like this:

Accept Top-Up Terms and Conditions* and Deals Terms and Conditions to proceed

But instead, I am getting this:

Accept [object Object] and [object Object] to proceed

Couldn’t find anything in the documentation. Is there a way to replace variables with components in i18n-js?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I got the same question and couldn't find an answer yet ...

maybe the Trans-Component could help:

https://react.i18next.com/latest/trans-component

Edit: This is maybe a good explanation React-i18n Trans Component with translations that contain HTML tags not working

Second Edit: I could solve the Problem with following code:

// render
<Trans i18nKey="yourTranslationKey" components={{ link: <Text onPress={() => console.log('do something')}}} /> }} />

// translationFile
{...
 "yourTranslationKey": "Please <link>Click me</link>",
...}

Found it on github :)

This is the official documentation about it.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!