Language selector: when reload it selects other language
When i pick a language in the language selector in Demo 1 Metronic 8 project, it sets the language correct, in my case to 'dk', and when it reloads the page it is set to 'en' again as it was before. The language is stored in localstorage. I set the new language as the localstorage value before reload, but at every reload it resets it to 'en'.
Is there anybody who can help?
(This is the first time i post a question on a support group, so please ask for more information if needed)
Hard to help you with this, the main setup works fine (https://preview.keenthemes.com/metronic8/react/demo1/dashboard.
Try to debug the place: 'how it's reading the initial language' (first, it should get from localStorage, if it's here). Maybe you have different localStorage keys for 'read/write' the language.
It is really wierd, but i changed the i18Config key name, so now there are two keys in my localstorage but i'm only looking at the new one. This fixed the functionality. I'm still not sure where the original key is set though.
Thanks for a quick response.
src/app/modules/i18n/translation.service.ts you will see the const
If the localStorage with this key is empty it returns the default language ('en').
If you want to deep dive into the localization theme, check the library documentation: https://github.com/ngx-translate/core, it's well documented and good configurable.