Skip to content

Commit

Permalink
Localize not implemented warning
Browse files Browse the repository at this point in the history
  • Loading branch information
holgerstolzenberg committed Mar 6, 2024
1 parent efb5ff4 commit 7916f48
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/app/i18n/i18n.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export class I18nService {
return this.translocoService.selectTranslate<string>(key);
}

translateMultiple(keys: string[]) {
return this.translocoService.selectTranslateObject(keys);
}

setActiveLang(languageCode: string) {
this.translocoService.setActiveLang(languageCode);
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/map/map.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
9 changes: 5 additions & 4 deletions src/app/notifications/notification.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);
}
}
3 changes: 3 additions & 0 deletions src/assets/i18n/de.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"common": {
"not-implemented": "Feature nicht implementiert"
},
"header": {
"title": "Europas Städte"
},
Expand Down
3 changes: 3 additions & 0 deletions src/assets/i18n/en.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"common": {
"not-implemented": "Feature not implemented"
},
"header": {
"title": "Cities of Europe"
},
Expand Down

0 comments on commit 7916f48

Please sign in to comment.