-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Is it safe to use reactI18nextModule on the server? #375
Comments
react-i18next does not solve the problem of having an i18n instance per request fixed to the language of that user...this is done by eg. https://github.com/i18next/i18next-express-middleware (same exists for koa and others) also checkout the samples for next and razzle: |
I guess |
the reactI18nextModule is just taking the i18next instance (i18next itself) https://github.com/i18next/react-i18next/blob/master/src/context.js#L29 (basically the global i18next instance - not the one from request) eg. for next.js: we use initialProps: https://github.com/i18next/react-i18next/blob/master/src/context.js#L29 for razzle: has entry point for server using the one on request: https://github.com/i18next/react-i18next/blob/master/example/razzle-ssr/src/server.js#L35 |
Ok I see, it's in fact a global: https://github.com/i18next/react-i18next/blob/master/src/context.js#L11 If what I say is correct it could make sense to make it clear in the documentation. |
think that makes sense...basically it's always about "injecting" the req.i18n so ssr case is rather tight coupled to i18next-express/koa-middleware |
I didn't find much documentation about
reactI18nextModule
and I was wondering if it's safe to use on the server considering that we could be rendering multiple pages for different languages at the same time.Would you mind explaining how the instance would be tied to a specific request?
The text was updated successfully, but these errors were encountered: