Change Language without reloading page
centigrade-julian-lang opened this issue · 2 comments
Hi, I am new to i18next and your package - so sorry if this question is somehow obvious to solve or something. :)
I want to change the displayed language on the fly (so without reloading the page; in order to keep application-state). After digging a bit into the code, I saw that the I18NextPipe
is marked as pure: true
(implicitly, by omitting the property).
As I understand it, this means that Angular will only evaluate the value for each translation-key once, caches this value and after it reuses the cached value for further requests for that specific key. If so, this would make something like a live-change of the language, practically impossible.
Am I correct, and is there any way or plan to enable a dynamic language change without reloading?
Btw, I tried this code, but it did not work, unfortunately:
class MyAngularComponent {
// gets called as event handler from template:
async changeLang(lang: string) {
await this.i18NextService.changeLanguage(lang);
this.changeDetectorRef.detectChanges();
// commented the reload out:
// document.location.reload();
}
}
Thanks in advance!
@centigrade-julian-lang Hi, i18nextEager made for that. Look information at repos readme.md file
@Romanchuk Thank you a lot :)