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

174
Views
React-i18next adding translated text to {t} function

I've made a React project where I'm using i18n for localization. Translation works like it should, here is an example.

import React, { Suspense } from "react";
import i18n from "i18next";
import { initReactI18next, useTranslation } from "react-i18next";

const translationSwe = {
about: "Information"
}

const translationEng = {
about: "About"
}

i18n.use(initReactI18next).init({
resources: {
swe: { translation: translationSwe },
eng: { translation: translationEng },
},
lng: "swe",
fallbackLng: "swe",
interpolation: { escapeValue: false },
});

const App = () => {
const { t } = useTranslation();

return(
<Suspense fallback="Loading..">
  <div className="app">
   <p>{t("about")}</p>
  </div>
</Suspense>
 );
};

I was just wondering, is there a way to add translated text without getting it from translationSwe & translatioEng? This doesn't work of course, but something like this was on my mind:

<p>{t(swe: "Information", eng: "About")}</p>

Hopefully you get the idea, please ask if not!

about 4 years ago · Juan Pablo Isaza
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!