diff --git a/src/app/web-app.component.ts b/src/app/web-app.component.ts index f3f757ab3..a3ccae8c6 100644 --- a/src/app/web-app.component.ts +++ b/src/app/web-app.component.ts @@ -187,13 +187,22 @@ export class WebAppComponent implements OnInit, OnDestroy { takeUntil(this.destroy$) ) .subscribe((event) => { - const title = event['title'] ? `labels.text.${event['title']}` : 'APP_NAME'; - this.i18nService - .translate(title) - .pipe(take(1)) - .subscribe((titleTranslated: any) => { - this.titleService.setTitle(titleTranslated); - }); + if (!event['title']) { + this.i18nService.translate('APP_NAME').pipe(take(1)).subscribe((t: any) => this.titleService.setTitle(t)); + return; + } + const raw = event['title']; + const textKey = `labels.text.${raw}`; + const menuKey = `labels.menus.${raw}`; + this.i18nService.translate(textKey).pipe(take(1)).subscribe((textResult: any) => { + if (textResult !== textKey) { + this.titleService.setTitle(textResult); + } else { + this.i18nService.translate(menuKey).pipe(take(1)).subscribe((menuResult: any) => { + this.titleService.setTitle(menuResult !== menuKey ? menuResult : raw); + }); + } + }); }); // Stores top 100 user activites as local storage object.