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

Abdelrhman Gad
  • 195
  • 2
  • 11

1 Answers1

0

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

Abdelrhman Gad
  • 195
  • 2
  • 11