From 36e213bbbfbff6a97b837c799965805455bfa082 Mon Sep 17 00:00:00 2001 From: HardiReady Date: Thu, 4 Oct 2018 13:06:14 +0200 Subject: [PATCH] Replace strings with i18n keys in request module --- .../common/show-error/show-error.component.ts | 2 +- .../request/award/req-award.component.html | 42 ++++++----- .../app/request/award/req-award.component.ts | 8 +-- .../confirm-award.component.html | 25 ++++--- .../confirm-promotion.component.html | 36 ++++++---- .../promotion/req-promotion.component.html | 40 ++++++----- .../promotion/req-promotion.component.ts | 1 - static/src/app/request/request.component.ts | 6 +- static/src/app/request/request.module.ts | 33 ++++++++- static/src/app/request/request.routing.ts | 56 ++++++++------- .../sql-dashboard.component.html | 28 ++++---- static/src/assets/i18n/request/de.json | 72 +++++++++++++++++++ static/src/assets/i18n/request/en.json | 2 + 13 files changed, 244 insertions(+), 107 deletions(-) create mode 100644 static/src/assets/i18n/request/de.json create mode 100644 static/src/assets/i18n/request/en.json diff --git a/static/src/app/common/show-error/show-error.component.ts b/static/src/app/common/show-error/show-error.component.ts index dd2bf09..9496843 100644 --- a/static/src/app/common/show-error/show-error.component.ts +++ b/static/src/app/common/show-error/show-error.component.ts @@ -11,7 +11,7 @@ import {TranslateService} from '@ngx-translate/core'; ` }) -export class ShowErrorComponent implements OnInit{ +export class ShowErrorComponent implements OnInit { // tslint:disable-next-line:no-input-rename @Input('controlPath') controlPath; diff --git a/static/src/app/request/award/req-award.component.html b/static/src/app/request/award/req-award.component.html index 245e062..ecbcab1 100644 --- a/static/src/app/request/award/req-award.component.html +++ b/static/src/app/request/award/req-award.component.html @@ -1,8 +1,8 @@
-

Auszeichnung beantragen

+

{{'request.award.headline' | translate}}

- + - + @@ -44,35 +44,35 @@
- + + id="reason" placeholder="{{'request.award.field.reason.placeholder' | translate}}" rows="3">
- - - - - - - + + + + + + + @@ -96,7 +96,15 @@ {{award.date | date: 'dd.MM.yyyy'}}
BildBezeichnungBegründungAntragstellerDatumStatusGrund für Ablehnung{{'request.award.table.head.image' | translate}}{{'request.award.table.head.name' | translate}}{{'request.award.table.head.reason' | translate}}{{'request.award.table.head.requester' | translate}}{{'request.award.table.head.date' | translate}}{{'request.award.table.head.status' | translate}}{{'request.award.table.head.reject.reason' | translate}}
- {{award.confirmed === 0? 'In Bearbeitung' : (award.confirmed === 1? 'Genehmigt' : 'Abgelehnt')}} + + {{'request.award.table.status.progressing' | translate}} + + + {{'request.award.table.status.accepted' | translate}} + + + {{'request.award.table.status.rejected' | translate}} + {{award.rejectReason ? award.rejectReason : ''}} diff --git a/static/src/app/request/award/req-award.component.ts b/static/src/app/request/award/req-award.component.ts index d0de1fb..380e8aa 100644 --- a/static/src/app/request/award/req-award.component.ts +++ b/static/src/app/request/award/req-award.component.ts @@ -82,10 +82,10 @@ export class RequestAwardComponent implements OnInit { addAwarding(previewImage, descriptionField) { if (this.decoration._id && this.reason.length > 0) { const award: Award = { - 'userId': this.user._id, - 'decorationId': this.decoration._id, - 'reason': this.reason, - 'date': Date.now() + userId: this.user._id, + decorationId: this.decoration._id, + reason: this.reason, + date: Date.now() }; this.awardingService.requestAwarding(award).subscribe(() => { this.awardingService.getUserAwardings(this.user._id) diff --git a/static/src/app/request/confirm-award/confirm-award.component.html b/static/src/app/request/confirm-award/confirm-award.component.html index 8725080..ba2eac2 100644 --- a/static/src/app/request/confirm-award/confirm-award.component.html +++ b/static/src/app/request/confirm-award/confirm-award.component.html @@ -1,18 +1,18 @@ -

Offene Anträge - Auszeichnungen

+

{{'request.confirm.award.headline' | translate}}

- + - - - - + + + + - + @@ -43,16 +43,19 @@
Teilnehmer{{'request.confirm.award.table.head.participant' | translate}} AuszeichnungBegründungAntragstellerDatum{{'request.confirm.award.table.head.award' | translate}}{{'request.confirm.award.table.head.reason' | translate}}{{'request.confirm.award.table.head.requester' | translate}}{{'request.confirm.award.table.head.date' | translate}} Aktion{{'request.confirm.award.table.head.action' | translate}}
- Bestätigen
- Ablehnen + + {{'request.confirm.award.table.button.action.accept' | translate}} +
+ + {{'request.confirm.award.table.button.action.reject' | translate}} +
- diff --git a/static/src/app/request/confirm-promotion/confirm-promotion.component.html b/static/src/app/request/confirm-promotion/confirm-promotion.component.html index 6de86fe..40c449d 100644 --- a/static/src/app/request/confirm-promotion/confirm-promotion.component.html +++ b/static/src/app/request/confirm-promotion/confirm-promotion.component.html @@ -1,18 +1,18 @@
-

Offene Anträge - Beförderung

+

{{'request.confirm.promotion.headline' | translate}}

- - - - - - + + + + + + - + @@ -33,17 +33,29 @@ {{promotion.timestamp | date: 'dd.MM.yyyy'}} diff --git a/static/src/app/request/promotion/req-promotion.component.html b/static/src/app/request/promotion/req-promotion.component.html index 070e6b5..ed5e3ca 100644 --- a/static/src/app/request/promotion/req-promotion.component.html +++ b/static/src/app/request/promotion/req-promotion.component.html @@ -1,8 +1,8 @@ -

Beförderung beantragen

+

{{'request.promotion.headline' | translate}}

- +
- +
TeilnehmerAlter RangNeuer RangAntragstellerDatumStatus{{'request.confirm.promotion.table.head.participant' | translate}}{{'request.confirm.promotion.table.head.rank.before' | translate}}{{'request.confirm.promotion.table.head.rank.after' | translate}}{{'"request.confirm.promotion.table.head.requester' | translate}}{{'request.confirm.promotion.table.head.date' | translate}}{{'request.confirm.promotion.table.head.status' | translate}} Aktion{{'request.confirm.promotion.table.head.action' | translate}}
- {{promotion.confirmed === 0? 'In Bearbeitung' : (promotion.confirmed === 1? 'Genehmigt' : 'Abgelehnt')}} + + {{'request.confirm.promotion.table.status.progressing' | translate}} + + + {{'request.confirm.promotion.table.status.accepted' | translate}} + + + {{'request.confirm.promotion.table.status.rejected' | translate}} + - Bestätigen
- Ablehnen + + {{'request.confirm.promotion.table.button.action.accept' | translate}} +
+ + {{'request.confirm.promotion.table.button.action.reject' | translate}} +
- - - - - - - + + + + + + + @@ -89,10 +89,18 @@ {{promotion.timestamp | date: 'dd.MM.yyyy'}} diff --git a/static/src/app/request/promotion/req-promotion.component.ts b/static/src/app/request/promotion/req-promotion.component.ts index 709119d..3c369de 100644 --- a/static/src/app/request/promotion/req-promotion.component.ts +++ b/static/src/app/request/promotion/req-promotion.component.ts @@ -98,5 +98,4 @@ export class RequestPromotionComponent implements OnInit { return o1._id === o2._id; } } - } diff --git a/static/src/app/request/request.component.ts b/static/src/app/request/request.component.ts index 162bce1..ac2f515 100644 --- a/static/src/app/request/request.component.ts +++ b/static/src/app/request/request.component.ts @@ -1,11 +1,13 @@ import {Component} from '@angular/core'; +import {TranslateService} from '@ngx-translate/core'; @Component({ - selector: 'cc-request', + selector: 'cc-request-root', templateUrl: 'request.component.html', styleUrls: ['request.component.css'] }) export class RequestComponent { - constructor() { + constructor(private translate: TranslateService) { + translate.setDefaultLang('de'); } } diff --git a/static/src/app/request/request.module.ts b/static/src/app/request/request.module.ts index 593d2f4..da290fe 100644 --- a/static/src/app/request/request.module.ts +++ b/static/src/app/request/request.module.ts @@ -9,11 +9,38 @@ import {ConfirmPromotionComponent} from './confirm-promotion/confirm-promotion.c import {RequestAwardComponent} from './award/req-award.component'; import {RequestPromotionComponent} from './promotion/req-promotion.component'; import {SqlDashboardComponent} from './sql-dashboard/sql-dashboard.component'; +import {HttpClient} from '@angular/common/http'; +import {TranslateHttpLoader} from '@ngx-translate/http-loader'; +import {TranslateLoader, TranslateModule} from '@ngx-translate/core'; + +export function createTranslateLoader(http: HttpClient) { + return new TranslateHttpLoader(http, './assets/i18n/request/', '.json'); +} @NgModule({ - declarations: [RequestComponent, RequestPromotionComponent, RequestAwardComponent, ConfirmPromotionComponent, - ConfirmAwardComponent, SqlDashboardComponent, FilterRankPipe], - imports: [CommonModule, SharedModule, requestRouterModule] + declarations: [ + RequestComponent, + RequestPromotionComponent, + RequestAwardComponent, + ConfirmPromotionComponent, + ConfirmAwardComponent, + SqlDashboardComponent, + FilterRankPipe + ], + imports: [ + CommonModule, + SharedModule, + requestRouterModule, + + TranslateModule.forChild({ + loader: { + provide: TranslateLoader, + useFactory: (createTranslateLoader), + deps: [HttpClient] + }, + isolate: true + }) + ] }) export class RequestModule { static routes = requestRouterModule; diff --git a/static/src/app/request/request.routing.ts b/static/src/app/request/request.routing.ts index 172bfa3..66963f7 100644 --- a/static/src/app/request/request.routing.ts +++ b/static/src/app/request/request.routing.ts @@ -11,33 +11,37 @@ import {LoginGuardHL, LoginGuardSQL} from '../login'; import {SqlDashboardComponent} from './sql-dashboard/sql-dashboard.component'; -export const requestRoutes: Routes = [{ - path: '', component: RequestComponent -}, +export const requestRoutes: Routes = [ { - path: RouteConfig.requestAwardPath, - component: RequestAwardComponent, - canActivate: [LoginGuardSQL] - }, - { - path: RouteConfig.requestPromotionPath, - component: RequestPromotionComponent, - canActivate: [LoginGuardSQL] - }, - { - path: RouteConfig.sqlDashboardPath, - component: SqlDashboardComponent, - canActivate: [LoginGuardSQL] - }, - { - path: RouteConfig.confirmAwardPath, - component: ConfirmAwardComponent, - canActivate: [LoginGuardHL] - }, - { - path: RouteConfig.confirmPromotionPath, - component: ConfirmPromotionComponent, - canActivate: [LoginGuardHL] + path: '', + component: RequestComponent, + children: [ + { + path: RouteConfig.requestAwardPath, + component: RequestAwardComponent, + canActivate: [LoginGuardSQL] + }, + { + path: RouteConfig.requestPromotionPath, + component: RequestPromotionComponent, + canActivate: [LoginGuardSQL] + }, + { + path: RouteConfig.sqlDashboardPath, + component: SqlDashboardComponent, + canActivate: [LoginGuardSQL] + }, + { + path: RouteConfig.confirmAwardPath, + component: ConfirmAwardComponent, + canActivate: [LoginGuardHL] + }, + { + path: RouteConfig.confirmPromotionPath, + component: ConfirmPromotionComponent, + canActivate: [LoginGuardHL] + }, + ] }, ]; diff --git a/static/src/app/request/sql-dashboard/sql-dashboard.component.html b/static/src/app/request/sql-dashboard/sql-dashboard.component.html index efe1c07..99303d5 100644 --- a/static/src/app/request/sql-dashboard/sql-dashboard.component.html +++ b/static/src/app/request/sql-dashboard/sql-dashboard.component.html @@ -1,16 +1,16 @@
-

SQL Dashboard

+

{{'request.sql.dashboard.headline' | translate}}

- +
TeilnehmerAlter RangNeuer RangAntragstellerDatumStatusGrund für Ablehnung{{'request.promotion.table.head.participant' | translate}}{{'request.promotion.table.head.rank.before' | translate}}{{'request.promotion.table.head.rank.after' | translate}}{{'request.promotion.table.head.requester' | translate}}{{'request.promotion.table.head.date' | translate}}{{'request.promotion.table.head.status' | translate}}{{'request.promotion.table.head.reject.reason' | translate}}
- {{promotion.confirmed === 0? 'In Bearbeitung' : (promotion.confirmed === 1? 'Genehmigt' : 'Abgelehnt')}} + + {{'request.confirm.promotion.table.status.progressing' | translate}} + + + {{'request.confirm.promotion.table.status.accepted' | translate}} + + + {{'request.confirm.promotion.table.status.rejected' | translate}} + - {{promotion.rejectReason ? promotion.rejectReason : ''}} + {{promotion.rejectReason}}
- - - - - + + + + + @@ -36,16 +36,16 @@
- +
TeilnehmerAlter RangNeuer RangAntragstellerDatum{{'request.confirm.promotion.table.head.participant' | translate}}{{'request.confirm.promotion.table.head.rank.before' | translate}}{{'request.confirm.promotion.table.head.rank.after' | translate}}{{'request.confirm.promotion.table.head.requester' | translate}}{{'request.confirm.promotion.table.head.date' | translate}}
- - - - - - + + + + + + diff --git a/static/src/assets/i18n/request/de.json b/static/src/assets/i18n/request/de.json new file mode 100644 index 0000000..49e27a5 --- /dev/null +++ b/static/src/assets/i18n/request/de.json @@ -0,0 +1,72 @@ +{ + "public.error.message.required": "{{fieldName}} ist ein Pflichtfeld", + "public.error.message.min.length": "{{fieldName}} muss mindestens {{boundary}} Zeichen enthalten", + "public.error.message.max.length": "{{fieldName}} darf maximal {{boundary}} Zeichen enthalten", + "public.error.message.email": "Bitte geben Sie eine gültige E-Mail Adresse an", + "public.error.message.no.user": "Der eingetragene Benutzer existiert nicht.", + "public.error.message.default": "{{fieldName}} ist nicht valide", + "public.common.search.button": "Suchen", + + "request.confirm.award.headline": "Offene Anträge - Auszeichnungen", + "request.confirm.award.table.head.participant": "Teilnehmer", + "request.confirm.award.table.head.award": "Auszeichnung", + "request.confirm.award.table.head.reason": "Begründung", + "request.confirm.award.table.head.requester": "Antragsteller", + "request.confirm.award.table.head.date": "Datum", + "request.confirm.award.table.head.action": "Aktion", + "request.confirm.award.table.reject.reason.placeholder": "Begründung für Ablehnung (optional)", + "request.confirm.award.table.button.action.accept": "Bestätigen", + "request.confirm.award.table.button.action.reject": "Ablehnen", + + "request.confirm.promotion.headline": "Offene Anträge - Beförderungen", + "request.confirm.promotion.table.head.participant": "Teilnehmer", + "request.confirm.promotion.table.head.rank.before": "Alter Rang", + "request.confirm.promotion.table.head.rank.after": "Neuer Rang", + "request.confirm.promotion.table.head.requester": "Antragsteller", + "request.confirm.promotion.table.head.date": "Datum", + "request.confirm.promotion.table.head.status": "Status", + "request.confirm.promotion.table.head.action": "Aktion", + "request.confirm.promotion.table.reject.reason.placeholder": "Begründung für Ablehnung (optional)", + "request.confirm.promotion.table.button.action.accept": "Bestätigen", + "request.confirm.promotion.table.button.action.reject": "Ablehnen", + "request.confirm.promotion.table.status.progressing": "In Bearbeitung", + "request.confirm.promotion.table.status.accepted": "Genehmigt", + "request.confirm.promotion.table.status.rejected": "Abgelehnt", + + "request.award.headline": "Auszeichnung beantragen", + "request.award.field.user": "Teilnehmer", + "request.award.field.user.placeholder": "Auswählen...", + "request.award.field.award": "Auszeichnung", + "request.award.field.award.placeholder": "Auswählen...", + "request.award.field.reason": "Begründung", + "request.award.field.reason.placeholder": "Begründung eingeben...", + "request.award.button.cancel": "Abbrechen", + "request.award.button.submit": "Bestätigen", + "request.award.table.head.image": "Bild", + "request.award.table.head.name": "Bezeichnung", + "request.award.table.head.reason": "Begründung", + "request.award.table.head.requester": "Antragsteller", + "request.award.table.head.date": "Datum", + "request.award.table.head.status": "Status", + "request.award.table.head.reject.reason": "Grund für Ablehnung", + "request.award.table.status.progressing": "In Bearbeitung", + "request.award.table.status.accepted": "Genehmigt", + "request.award.table.status.rejected": "Abgelehnt", + + "request.promotion.headline": "Beförderung beantragen", + "request.promotion.field.participant": "Teilnehmer", + "request.promotion.field.participant.placeholder": "Auswählen...", + "request.promotion.field.rank.before": "Aktueller Rang", + "request.promotion.field.rank.after": "Neuer Rang", + "request.promotion.button.submit": "Bestätigen", + "request.promotion.button.cancel": "Abbrechen", + "request.promotion.table.head.participant": "Teilnehmer", + "request.promotion.table.head.rank.before": "Alter Rang", + "request.promotion.table.head.rank.after": "Neuer Rang", + "request.promotion.table.head.requester": "Antragsteller", + "request.promotion.table.head.date": "Datum", + "request.promotion.table.head.status": "Status", + "request.promotion.table.head.reject.reason": "Grund für Ablehnung", + + "request.sql.dashboard.headline":"SQL Dashboard" +} diff --git a/static/src/assets/i18n/request/en.json b/static/src/assets/i18n/request/en.json new file mode 100644 index 0000000..2c63c08 --- /dev/null +++ b/static/src/assets/i18n/request/en.json @@ -0,0 +1,2 @@ +{ +}
TeilnehmerBildBezeichnungBegründungAntragstellerDatum{{'request.confirm.award.table.head.participant' | translate}}{{'request.confirm.award.table.head.award' | translate}}{{'request.confirm.award.table.head.reason' | translate}}{{'request.confirm.award.table.head.requester' | translate}}{{'request.confirm.award.table.head.date' | translate}}