Tom
Tom

Reputation: 3

Detect user language who visit my website (React, i18next)

I am developing a multilanguage application using React, i18next and i18next-browser-languagedetector.

i18next-browser-languagedetector detect user language in the browser with support for: cookie, localStorage, navigator, querystring, htmlTag

Should I verify Accept-Language from HTTP request header with another module ?

Upvotes: 0

Views: 3707

Answers (1)

jamuhl
jamuhl

Reputation: 4498

request headers get evaluated on the server side so not part of browser language detection -> the serverside middleware for eg. express comes with its own detector:

https://github.com/i18next/i18next-express-middleware#language-detection

also the serverside rendering examples for react-i18next use that: https://github.com/i18next/react-i18next/blob/master/example/nextjs/server.js#L16

Upvotes: 0

Related Questions