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

204
Views
React i18n, how to interpolate to a string (i.e. without using <Trans> component)?

I have this function in my React component:

const fireError = (n) => {
   alert(`The value should go over ${n}% to be accepted.`);
}

in my translation JSON I have this:

{ "percentage": "The value should go over {{percentage}} to be accepted" }

How can I make this work? Of course I cannot use the Trans component.

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

0

You can use the i18n service directly:

// import it
import i18n from "i18next";

// in your React component
const fireError = (n) => {
   alert(i18n.t('percentage', { percentage: n }));
}

Keep in mind that the library has to be initialized before calling this function - i18n.init() must have already been invoked.

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!