How to run 2 instances of ReactI18Next on the same app?

Viewed 162

I am trying to run 2 instances of React-i18Next on the same application. I want parts of my application to be translated with instance1 and parts of the application with instance2.

I've read about createInstance and i18nextprovider which I should use to create and run multiple instances. However, whatever I try I cannot seem to get it to work. I've also read this thread on github multiple times.

I have also created a codesandbox with my problem here: codesandbox demo.

Whatever I try, I cannot seem to get this to work and I am now even wondering if this is even possible with react-i18Next? Could someone take a look at my codesandbox example and tell me if it is even possible what I am trying to do and if so, what I am doing wrong?

1 Answers

Would the following work?

const { t, i18n } = useTranslation();
const { t: t2, i18n: i18n2: } = useTranslation();

The way the second useTranslation()'s variables are destructured rename the default variables so they can be used however you like to seperately.

Related