diff --git a/dmp-frontend/src/app/app.component.ts b/dmp-frontend/src/app/app.component.ts index 999752643..7fd33fb2d 100644 --- a/dmp-frontend/src/app/app.component.ts +++ b/dmp-frontend/src/app/app.component.ts @@ -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(); }