Change app title on language change

This commit is contained in:
gpapavgeri 2020-08-07 17:14:51 +03:00
parent a647ce9926
commit 995d5d75ee
1 changed files with 16 additions and 11 deletions

View File

@ -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();
}