ngx-translate/http-loader

subscribe to router event

AmitXShukla opened this issue · 0 comments

I have ngx-translate ChangeLanguage function on navigation (nav is insert on every component), it works fine and translates text as per json in given component.
However, when user routes to another component through [routerLink]=, it forgets about earlier language selection made.
How can I make app remember, earlier language preference?

ngOnInit() {
// subscribe to router event
this.subscription_translate = this.activatedRoute.queryParams.subscribe(
(param: any) => {
let locale = param['locale'];
if (locale !== undefined) {
this._translate.use(locale);
}
});
}