Change app title on language change
This commit is contained in:
parent
a647ce9926
commit
995d5d75ee
|
@ -100,17 +100,8 @@ export class AppComponent implements OnInit {
|
||||||
return appTitle;
|
return appTitle;
|
||||||
})
|
})
|
||||||
).subscribe((ttl: string) => {
|
).subscribe((ttl: string) => {
|
||||||
if (ttl.length > 0) {
|
this.translateTitle(ttl);
|
||||||
this.translate.get(ttl).subscribe((translated: string) => {
|
this.translate.onLangChange.subscribe(() => this.translateTitle(ttl));
|
||||||
this.translate.get('GENERAL.TITLES.PREFIX').subscribe((titlePrefix: string) => {
|
|
||||||
this.titleService.setTitle(titlePrefix + translated);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.translate.get('GENERAL.TITLES.GENERAL').subscribe((translated: string) => {
|
|
||||||
this.titleService.setTitle(translated);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.statusChangeSubscription = this.ccService.statusChange$.subscribe((event: NgcStatusChangeEvent) => {
|
this.statusChangeSubscription = this.ccService.statusChange$.subscribe((event: NgcStatusChangeEvent) => {
|
||||||
|
@ -140,6 +131,20 @@ export class AppComponent implements OnInit {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
translateTitle(ttl: string) {
|
||||||
|
if (ttl.length > 0) {
|
||||||
|
this.translate.get(ttl).subscribe((translated: string) => {
|
||||||
|
this.translate.get('GENERAL.TITLES.PREFIX').subscribe((titlePrefix: string) => {
|
||||||
|
this.titleService.setTitle(titlePrefix + translated);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.translate.get('GENERAL.TITLES.GENERAL').subscribe((translated: string) => {
|
||||||
|
this.titleService.setTitle(translated);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
this.statusChangeSubscription.unsubscribe();
|
this.statusChangeSubscription.unsubscribe();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue