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;
|
||||
})
|
||||
).subscribe((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);
|
||||
});
|
||||
}
|
||||
this.translateTitle(ttl);
|
||||
this.translate.onLangChange.subscribe(() => this.translateTitle(ttl));
|
||||
});
|
||||
|
||||
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() {
|
||||
this.statusChangeSubscription.unsubscribe();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue