0

I'm trying to use i18next for localtization, it works well as it translates english text to arabic {t("title")} ==> مرحبا. But when i try to change language to english with const { t, i18n } = useTranslation() i18n.changeLanguage('en') it dosen't change. How to fix this.

I got that error at server vscode terimanl react-i18next:: You will need to pass in an i18next instance by using initReactI18next

1 Answer 1

1

I found the solution at nextjs Docs. It seems changing locales at nextjs not the same as reactjs, with invoking i18n.changeLanguage('en'). But instead use.

<Link href="/fr/another" locale="en">
  <a>To /fr/another</a>
</Link>

Will do the job. more information: https://nextjs.org/docs/advanced-features/i18n-routing

Not the answer you're looking for? Browse other questions tagged or ask your own question.