Search code examples
react-apolloi18nextreact-i18next

When exactly does i18n.languages get set?


I have an express server, am using apollo-client and also i18next for translations. What I need to do is to set the apollo-client link to have the users language in it. When I console.log i18n it's initialized but it's missing the i18n.languages[0] so I can't get the current language.

The setup of the i18next is the latest example.


Solution

  • In the middleware on each request: https://github.com/i18next/i18next-express-middleware/blob/master/src/index.js#L40 but only on the i18next instance bound to this request - not the global one!