0

I have an app with next.js and next-i18next for the internationalization. I need to store the current locale and I'm trying to figure out how to do it. maybe in the _app.tsx or the _document.tsx/ where do I get the current locale? from the instance or the context?

brc-dd
  • 10,788
  • 3
  • 47
  • 67
  • 1
    You can access it e.g. in every component by using: `const {i18n} = useTranslation(); console.log(i18n.language);`. If you need to store it inside Redux you can then dispatch an action with `i18n.language` as value. Where you want to do this, is up to you. – r3dst0rm Aug 04 '20 at 08:32

1 Answers1

-1

Current settings is in i18next.language. When you want to know what language is set just import i18n instance i.e. import i18n from '../../i18n'. Instance is created using i18n.init().

miuosh
  • 836
  • 3
  • 12
  • 35