From 7916f48196a6ea08024d42455223356296dfbcdd Mon Sep 17 00:00:00 2001 From: Holger Stolzenberg Date: Wed, 6 Mar 2024 11:52:43 +0100 Subject: [PATCH] Localize not implemented warning --- src/app/i18n/i18n.service.ts | 4 ++++ src/app/map/map.component.ts | 4 ++-- src/app/notifications/notification.service.ts | 9 +++++---- src/assets/i18n/de.json | 3 +++ src/assets/i18n/en.json | 3 +++ 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/app/i18n/i18n.service.ts b/src/app/i18n/i18n.service.ts index 27fa7a6..c8c3f01 100644 --- a/src/app/i18n/i18n.service.ts +++ b/src/app/i18n/i18n.service.ts @@ -13,6 +13,10 @@ export class I18nService { return this.translocoService.selectTranslate(key); } + translateMultiple(keys: string[]) { + return this.translocoService.selectTranslateObject(keys); + } + setActiveLang(languageCode: string) { this.translocoService.setActiveLang(languageCode); } diff --git a/src/app/map/map.component.ts b/src/app/map/map.component.ts index 904e033..57d4749 100644 --- a/src/app/map/map.component.ts +++ b/src/app/map/map.component.ts @@ -73,12 +73,12 @@ export class MapComponent implements OnInit, AfterViewInit, OnDestroy { // TODO deck.gl: this.resetMap(); this.mapService.resetMap$.pipe(takeUntil(this.onUnsubscribe$)).subscribe(() => { - this.notificationService.showWarn('Not implemented yet'); + this.notificationService.showWarnLocalized('common.not-implemented'); }); // TODO deck.gl: this.myLocation(); this.mapService.toMyLocation$.pipe(takeUntil(this.onUnsubscribe$)).subscribe(() => { - this.notificationService.showWarn('Not implemented yet'); + this.notificationService.showWarnLocalized('common.not-implemented'); }); this.mapService.showEuBorders$.pipe(takeUntil(this.onUnsubscribe$)).subscribe(value => { diff --git a/src/app/notifications/notification.service.ts b/src/app/notifications/notification.service.ts index 92c3d9e..7294a1b 100644 --- a/src/app/notifications/notification.service.ts +++ b/src/app/notifications/notification.service.ts @@ -27,10 +27,11 @@ export class NotificationService { ); } - showWarn(message: string) { - this.log.warn(message); - firstValueFrom(this.i18nService.translate('notifications.warn-title')).then(title => - this.toastrService.warning(message, title, options) + showWarnLocalized(messageKey: string) { + this.log.warn(messageKey); + + firstValueFrom(this.i18nService.translateMultiple(['notifications.warn-title', messageKey])).then(values => + this.toastrService.warning(values[1], values[0], options) ); } } diff --git a/src/assets/i18n/de.json b/src/assets/i18n/de.json index 7fe863e..b3a81da 100644 --- a/src/assets/i18n/de.json +++ b/src/assets/i18n/de.json @@ -1,4 +1,7 @@ { + "common": { + "not-implemented": "Feature nicht implementiert" + }, "header": { "title": "Europas Städte" }, diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index 82360c1..d820e6c 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -1,4 +1,7 @@ { + "common": { + "not-implemented": "Feature not implemented" + }, "header": { "title": "Cities of Europe" },