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

209
Views
React i18n, ¿cómo interpolar a una cadena (es decir, sin usar el componente <Trans>)?

Tengo esta función en mi componente React:

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

en mi traducción JSON tengo esto:

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

¿Cómo puedo hacer que esto funcione? Por supuesto que no puedo usar el componente Trans.

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

0

Puede utilizar el servicio i18n directamente:

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

Tenga en cuenta que la biblioteca debe inicializarse antes de llamar a esta función: ya se debe haber invocado i18n.init() .

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!