You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can do it on the server, when the initial request is made.
You need to pass req.acceptsLanguage(/* variadic list of languages in
descending order */) as a prop to IntlProvider. This will look for the
accept-language header, that a browser sends automatically, and match each
value from your list of languages in the arguments of acceptsLanguage
function with possible values from the header. The first value to match is
a winner.
Then inside of the constructor (yes that thing with super() call) of
IntlProvider you need to fire an action (it won't be an API request, just
an object configuration, so it is ok to do it there), that will accept that
prop with a matched language.
Taking into consideration, that there could be no match or the language is
not supported by your code base, you should have a supported languages
array and search for the matched language in this array. If everything is
ok then set the matched language as your app language via
i18next.changeLanguage, if not, do the same with your default or favorite
language)
I hope, you'll make it))
I'm try find a way to enable in i18Next the automatic switch language based on browser. Do you know how configure it? Thanks.
The text was updated successfully, but these errors were encountered: