Search code examples
i18nexti18next-browser-languagedetector

i18next force detect language again


I'm using the browser language detector for i18next.

I'm using the default precedence, which is

['querystring', 'cookie', 'localStorage', 'navigator', 'htmlTag', 'path', 'subdomain']

I want to be able to set localStorage.i18nextLng dynamically, and have i18next update the language, but still respect the detection precedence.

Is there a way to tell i18next to run the language detector again? Or is there another way to accomplish this?


Solution

  • You can change the local storage value and then trigger i18next.changeLanguage() to change on runtime.