Reputation: 5629
I use i18n (react-i18next
) in my react js application. Translation with language chooser etc works absolutly fine.
But now I want to change some texts programmatically on demand.
I tried this:
i18n.t('clinical:sde.export.studyTitle', {lng: "en"})
and
i18n.t('clinical:sde.export.studyTitle', {"en"})
It always returns the german string from current setting and not the "on demand" english text. Is there a solution to solve this?
Thanks in advance.
Upvotes: 0
Views: 918
Reputation: 35603
Your code should work, you need to check that the dynamic language is loaded (this what i18n.changeLanguage
does).
I've made a simple test, and it works.
https://codesandbox.io/s/react-i18next-example-forked-ueng1?file=/src/app.js
Upvotes: 1