diff --git a/src/app/app.component.html b/src/app/app.component.html index 9000684f..25373329 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -11,8 +11,8 @@ {{ 'app.user-manual' | translate }} 🇬🇧 English @@ -35,8 +35,8 @@ ; + protected localStorageLanguage: string; projectInMenu: Observable; @@ -45,8 +47,10 @@ export class AppComponent { private trainrunSectionService: TrainrunSectionService, private nodeService: NodeService, private labelService: LabelService, + private i18nService: I18nService, ) { - this.language = localStorage.getItem("i18nLng"); + this.i18nService.setLanguage(); + this.localStorageLanguage = localStorage.getItem("i18nLng"); if (!this.disableBackend) { this.authenticated = authService.initialized; } @@ -58,14 +62,15 @@ export class AppComponent { } } - changeLanguage(language: string) { - localStorage.setItem("i18nLng", language); - this.language = language; - location.reload(); + @Input() + set language(value: string) { + if (value !== this.localStorageLanguage) { + localStorage.setItem("i18nLng", value); + this.i18nService.setLanguage(); + this.localStorageLanguage = localStorage.getItem("i18nLng"); + } } - @Input() language: string; - @Input() get netzgrafikDto() { return this.dataService.getNetzgrafikDto();