From cd942f22d313f5daaf78ad20dc42ae9a0ae25a84 Mon Sep 17 00:00:00 2001
From: Vinciane <vinciane.bizet@maarch.org>
Date: Tue, 16 Apr 2019 12:34:21 +0200
Subject: [PATCH] FEAT #8805 Translate modal field

---
 src/frontend/app/modal/confirm-modal.component.html  |  9 ++++-----
 src/frontend/app/modal/confirm-modal.component.ts    | 10 ++++++----
 src/frontend/app/modal/reject-info.component.ts      |  4 +++-
 src/frontend/app/modal/reject-info.html              |  4 ++--
 .../app/modal/success-info-valid.component.ts        |  4 +++-
 src/frontend/app/modal/success-info-valid.html       |  4 ++--
 src/frontend/app/modal/warn-modal.component.html     | 10 +++++-----
 src/frontend/app/modal/warn-modal.component.ts       | 12 +++++++-----
 src/frontend/assets/i18n/en.json                     | 12 ++++++++++++
 src/frontend/assets/i18n/fr.json                     | 12 ++++++++++++
 10 files changed, 56 insertions(+), 25 deletions(-)

diff --git a/src/frontend/app/modal/confirm-modal.component.html b/src/frontend/app/modal/confirm-modal.component.html
index 51c6429c7a..bfe34c1c31 100755
--- a/src/frontend/app/modal/confirm-modal.component.html
+++ b/src/frontend/app/modal/confirm-modal.component.html
@@ -1,17 +1,16 @@
 <div class="modalContent">
   <h1 mat-dialog-title class="default" *ngIf="signaturesService.signaturesContent.length > 0 || signaturesService.notesContent.length > 0"><i
-      class="fa fa-question-circle fa-2x"></i><br />{{data.msg}}</h1>
+      class="fa fa-question-circle fa-2x"></i><br />{{data.msg | translate}}</h1>
   <h1 mat-dialog-title style="color: #f5a623;font-weight: bold;" *ngIf="signaturesService.signaturesContent.length == 0 && signaturesService.notesContent.length == 0"><i
-      class="fa fa-exclamation-triangle fa-2x"></i><br />Attention !</h1>
+      class="fa fa-exclamation-triangle fa-2x"></i><br />{{'lang.attention' | translate}} !</h1>
   <div mat-dialog-content>
-    <p *ngIf="signaturesService.signaturesContent.length == 0 && signaturesService.notesContent.length == 0">Vous êtes
-      sur le point de valider ce document sans signature ou annotation!</p>
+    <p *ngIf="signaturesService.signaturesContent.length == 0 && signaturesService.notesContent.length == 0">{{'lang.validateDocumentWithoutSignOrNote' | translate}}</p>
   </div>
   <div mat-dialog-actions>
     <button mat-icon-button class="close" (click)="this.dialogRef.close();">
       <mat-icon fontSet="fas" fontIcon="fa-times"></mat-icon>
     </button>
     <button class="actions btn green" mat-button (click)="confirmDoc();" [disabled]="disableState"><i class="fas fa-check-circle fa-2x"></i>
-      {{ msgButton }}</button>
+      {{ msgButton | translate}}</button>
   </div>
 </div>
\ No newline at end of file
diff --git a/src/frontend/app/modal/confirm-modal.component.ts b/src/frontend/app/modal/confirm-modal.component.ts
index 950774914b..eb7e1f453e 100644
--- a/src/frontend/app/modal/confirm-modal.component.ts
+++ b/src/frontend/app/modal/confirm-modal.component.ts
@@ -3,6 +3,8 @@ import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material';
 import { SignaturesContentService } from '../service/signatures.service';
 import { NotificationService } from '../service/notification.service';
 import { HttpClient } from '@angular/common/http';
+import { TranslateService } from '@ngx-translate/core';
+import {_} from '@biesbjerg/ngx-translate-extract/dist/utils/utils';
 
 @Component({
     templateUrl: 'confirm-modal.component.html',
@@ -10,9 +12,9 @@ import { HttpClient } from '@angular/common/http';
 })
 export class ConfirmModalComponent {
     disableState = false;
-    msgButton = 'Valider';
+    msgButton = 'lang.validate';
 
-    constructor(@Inject(MAT_DIALOG_DATA) public data: any, public http: HttpClient, public dialogRef: MatDialogRef<ConfirmModalComponent>, public signaturesService: SignaturesContentService, public notificationService: NotificationService) { }
+    constructor(private translate: TranslateService, @Inject(MAT_DIALOG_DATA) public data: any, public http: HttpClient, public dialogRef: MatDialogRef<ConfirmModalComponent>, public signaturesService: SignaturesContentService, public notificationService: NotificationService) { }
 
     confirmDoc () {
         const signatures: any[] = [];
@@ -59,12 +61,12 @@ export class ConfirmModalComponent {
                         }
                     }
                     this.disableState = false;
-                    this.msgButton = 'Valider';
+                    this.msgButton = 'lang.validate';
                     this.dialogRef.close('sucess');
                 }, (err: any) => {
                     this.notificationService.handleErrors(err);
                     this.disableState = false;
-                    this.msgButton = 'Valider';
+                    this.msgButton = 'lang.validate';
                 });
         } else {
             this.dialogRef.close('sucess');
diff --git a/src/frontend/app/modal/reject-info.component.ts b/src/frontend/app/modal/reject-info.component.ts
index 5c90cdc42d..31fe9440f2 100644
--- a/src/frontend/app/modal/reject-info.component.ts
+++ b/src/frontend/app/modal/reject-info.component.ts
@@ -2,6 +2,8 @@ import { Component, OnInit } from '@angular/core';
 import { Router } from '@angular/router';
 import { SignaturesContentService } from '../service/signatures.service';
 import { MatBottomSheetRef } from '@angular/material';
+import { TranslateService } from '@ngx-translate/core';
+import {_} from '@biesbjerg/ngx-translate-extract/dist/utils/utils';
 
 @Component({
     templateUrl: '../modal/reject-info.html',
@@ -9,7 +11,7 @@ import { MatBottomSheetRef } from '@angular/material';
 })
 export class RejectInfoBottomSheetComponent implements OnInit {
     date: Date = new Date();
-    constructor(private router: Router, public signaturesService: SignaturesContentService, private bottomSheetRef: MatBottomSheetRef<RejectInfoBottomSheetComponent>) { }
+    constructor(private translate: TranslateService, private router: Router, public signaturesService: SignaturesContentService, private bottomSheetRef: MatBottomSheetRef<RejectInfoBottomSheetComponent>) { }
     ngOnInit(): void {
         setTimeout(() => {
             if (this.signaturesService.documentsList[this.signaturesService.indexDocumentsList]) {
diff --git a/src/frontend/app/modal/reject-info.html b/src/frontend/app/modal/reject-info.html
index c732e6db02..d248fdc03d 100755
--- a/src/frontend/app/modal/reject-info.html
+++ b/src/frontend/app/modal/reject-info.html
@@ -1,7 +1,7 @@
 <div class="red" style="text-align: center;">
   <h1><i class="fa fa-thumbs-down fa-4x"></i></h1>
-  <p>Document refusé en tant que :</p>
+  <p>{{'lang.documentRefusedAs' | translate}}</p>
 
   <p style="font-weight:bold;font-size: 30px;">{{signaturesService.userLogged.firstname}} {{signaturesService.userLogged.lastname}}</p>
-  <p style="font-weight:bold;font-size: 15px;">le {{date | date:'dd/MM/yyyy'}} à {{date | date:'HH:mm'}}</p>
+  <p style="font-weight:bold;font-size: 15px;">{{'lang.onRange' | translate}} {{date | date:'dd/MM/yyyy'}} {{'lang.atRange' | translate}} {{date | date:'HH:mm'}}</p>
 </div>
diff --git a/src/frontend/app/modal/success-info-valid.component.ts b/src/frontend/app/modal/success-info-valid.component.ts
index a28f530434..276835d69d 100644
--- a/src/frontend/app/modal/success-info-valid.component.ts
+++ b/src/frontend/app/modal/success-info-valid.component.ts
@@ -2,6 +2,8 @@ import { Component, OnInit } from '@angular/core';
 import { Router } from '@angular/router';
 import { SignaturesContentService } from '../service/signatures.service';
 import { MatBottomSheetRef } from '@angular/material';
+import { TranslateService } from '@ngx-translate/core';
+import {_} from '@biesbjerg/ngx-translate-extract/dist/utils/utils';
 
 @Component({
     templateUrl: 'success-info-valid.html',
@@ -9,7 +11,7 @@ import { MatBottomSheetRef } from '@angular/material';
 })
 export class SuccessInfoValidBottomSheetComponent implements OnInit {
     date: Date = new Date();
-    constructor(private router: Router, public signaturesService: SignaturesContentService, private bottomSheetRef: MatBottomSheetRef<SuccessInfoValidBottomSheetComponent>) { }
+    constructor(private translate: TranslateService, private router: Router, public signaturesService: SignaturesContentService, private bottomSheetRef: MatBottomSheetRef<SuccessInfoValidBottomSheetComponent>) { }
      ngOnInit(): void {
         setTimeout(() => {
             if (this.signaturesService.documentsList[this.signaturesService.indexDocumentsList]) {
diff --git a/src/frontend/app/modal/success-info-valid.html b/src/frontend/app/modal/success-info-valid.html
index a903174925..c963f07f86 100755
--- a/src/frontend/app/modal/success-info-valid.html
+++ b/src/frontend/app/modal/success-info-valid.html
@@ -1,7 +1,7 @@
 <div class="green" style="text-align: center;">
   <h1><i class="fa fa-thumbs-up fa-4x"></i></h1>
-  <p>Document validé en tant que :</p>
+  <p>{{'lang.documentValidateAs' | translate}}</p>
 
   <p style="font-weight:bold;font-size: 30px;">{{signaturesService.userLogged.firstname}} {{signaturesService.userLogged.lastname}}</p>
-  <p style="font-weight:bold;font-size: 15px;">le {{date | date:'dd/MM/yyyy'}} à {{date | date:'HH:mm'}}</p>
+  <p style="font-weight:bold;font-size: 15px;">{{'lang.onRange' | translate}} {{date | date:'dd/MM/yyyy'}} {{'lang.atRange' | translate}} {{date | date:'HH:mm'}}</p>
 </div>
diff --git a/src/frontend/app/modal/warn-modal.component.html b/src/frontend/app/modal/warn-modal.component.html
index 65c3dd128b..3665db85d5 100755
--- a/src/frontend/app/modal/warn-modal.component.html
+++ b/src/frontend/app/modal/warn-modal.component.html
@@ -1,14 +1,14 @@
 <div class="modalContent">
-    <h1 mat-dialog-title><i class="fa fa-exclamation-triangle fa-2x"></i><br/>Attention !</h1>
+    <h1 mat-dialog-title><i class="fa fa-exclamation-triangle fa-2x"></i><br/>{{'lang.attention' | translate}} !</h1>
     <div mat-dialog-content>
-      <p *ngIf="signaturesService.notesContent.length == 0 && signaturesService.signaturesContent.length == 0">Vous êtes sur le point de refuser ce document sans annotation !</p>
-      <p *ngIf="signaturesService.notesContent.length > 0 || signaturesService.signaturesContent.length > 0">Souhaitez-vous confirmer ?</p>
+      <p *ngIf="signaturesService.notesContent.length == 0 && signaturesService.signaturesContent.length == 0">{{'lang.refuseDocumentWithoutSignature' | translate}}</p>
+      <p *ngIf="signaturesService.notesContent.length > 0 || signaturesService.signaturesContent.length > 0">{{'lang.wouldLikeConfirm' | translate}} ?</p>
     </div>
     <div mat-dialog-actions>
       <button mat-icon-button class="close" (click)="this.dialogRef.close();">
         <mat-icon fontSet="fas" fontIcon="fa-times"></mat-icon>
       </button>
-      <button class="actions btn" [disabled]="disableState" mat-button (click)="this.dialogRef.close('annotation');" *ngIf="signaturesService.notesContent.length == 0"><i class="fas fa-pen-alt fa-2x"></i> Annoter ce document</button>
-      <button class="actions btn red" mat-button cdkFocusInitial (click)="confirmDoc();" [disabled]="disableState"><i class="fas fa-backspace fa-2x"></i> {{ msgButton }}</button>
+      <button class="actions btn" [disabled]="disableState" mat-button (click)="this.dialogRef.close('annotation');" *ngIf="signaturesService.notesContent.length == 0"><i class="fas fa-pen-alt fa-2x"></i> {{'lang.annotateDocument' | translate}}</button>
+      <button class="actions btn red" mat-button cdkFocusInitial (click)="confirmDoc();" [disabled]="disableState"><i class="fas fa-backspace fa-2x"></i> {{ msgButton | translate}}</button>
     </div>
 </div>
diff --git a/src/frontend/app/modal/warn-modal.component.ts b/src/frontend/app/modal/warn-modal.component.ts
index a93d421b24..58cb27d5f0 100644
--- a/src/frontend/app/modal/warn-modal.component.ts
+++ b/src/frontend/app/modal/warn-modal.component.ts
@@ -4,6 +4,8 @@ import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material';
 import { SignaturesContentService } from '../service/signatures.service';
 import { NotificationService } from '../service/notification.service';
 import { HttpClient } from '@angular/common/http';
+import { TranslateService } from '@ngx-translate/core';
+import {_} from '@biesbjerg/ngx-translate-extract/dist/utils/utils';
 
 @Component({
     templateUrl: 'warn-modal.component.html',
@@ -11,9 +13,9 @@ import { HttpClient } from '@angular/common/http';
 })
 export class WarnModalComponent {
     disableState = false;
-    msgButton = 'Refuser ce document';
+    msgButton = 'lang.rejectDocument';
 
-    constructor(@Inject(MAT_DIALOG_DATA) public data: any, public http: HttpClient, public dialogRef: MatDialogRef<WarnModalComponent>, public signaturesService: SignaturesContentService, public notificationService: NotificationService) { }
+    constructor(private translate: TranslateService, @Inject(MAT_DIALOG_DATA) public data: any, public http: HttpClient, public dialogRef: MatDialogRef<WarnModalComponent>, public signaturesService: SignaturesContentService, public notificationService: NotificationService) { }
 
     confirmDoc () {
         const signatures: any[] = [];
@@ -49,7 +51,7 @@ export class WarnModalComponent {
                 }
             }
             this.disableState = true;
-            this.msgButton = 'Envoi...';
+            this.msgButton = 'lang.sending';
             this.http.put('../rest/documents/' + this.signaturesService.mainDocumentId + '/actions/' + this.signaturesService.currentAction, {'signatures': signatures})
                 .subscribe(() => {
                     if (this.signaturesService.documentsList[this.signaturesService.indexDocumentsList] !== undefined) {
@@ -61,12 +63,12 @@ export class WarnModalComponent {
                         }
                     }
                     this.disableState = false;
-                    this.msgButton = 'Refuser ce document';
+                    this.msgButton = 'lang.rejectDocument';
                     this.dialogRef.close('sucess');
                 }, (err: any) => {
                     this.notificationService.handleErrors(err);
                     this.disableState = false;
-                    this.msgButton = 'Refuser ce document';
+                    this.msgButton = 'lang.rejectDocument';
                 });
         } else {
             this.dialogRef.close('sucess');
diff --git a/src/frontend/assets/i18n/en.json b/src/frontend/assets/i18n/en.json
index 2982deb60f..8e19f481e8 100755
--- a/src/frontend/assets/i18n/en.json
+++ b/src/frontend/assets/i18n/en.json
@@ -1,10 +1,13 @@
 {
 	"lang": {
 		"administrations": "Administrations",
+		"annotateDocument": "Annotate this document",
 		"annotationAdded": "Annotation added",
 		"annotationMode": "Annotation mode",
 		"appleStylus": "Apple stylus",
 		"areYouSure": "Are you sure?",
+		"atRange": "at",
+		"attention": "Attention",
 		"black": "Black",
 		"blue": "Blue",
 		"cancelPreviousNote": "Cancel the previous note",
@@ -17,6 +20,8 @@
 		"deleteNoteAndSignature": "Delete all annotations and signatures?",
 		"description": "Description",
 		"doc": "Doc",
+		"documentRefusedAs": "Document refused as a:",
+		"documentValidateAs": "Document validated as:",
 		"email": "Email",
 		"emittedBy": "Emitted by",
 		"exitAnnotation": "Exit the annotation",
@@ -24,6 +29,7 @@
 		"forgotPassword": "Forgot password",
 		"free": "Free",
 		"freeModeInfo": "",
+		"fromRange": "From",
 		"historyUseInfo": "You can't use the last <b>{{countPwd}}</b> passwords.",
 		"imageTooBig": "Image is too big (5mo max.)",
 		"informations": "Informations",
@@ -37,6 +43,7 @@
 		"noteAndSignatureDeleted": "Annotations / signatures deleted from the document",
 		"notifications": "Notifications",
 		"numberRequired": "1 number required",
+		"onRange": "on",
 		"open": "open",
 		"page": "page",
 		"password": "Password",
@@ -49,6 +56,8 @@
 		"receiveNotif": "Receive notifications",
 		"red": "Red",
 		"reference": "Reference",
+		"refuseDocumentWithoutSignature": "You are about to refuse this document without annotation!",
+		"rejectDocument": "Reject this document",
 		"renewalInfo": "Please note that this new password will only be valid on <b> {{time}} day(s) </ b>. After this time, you must choose a new one.",
 		"reply": "Reply",
 		"replySignatureAllPage": "Replicate the signature on all pages",
@@ -60,13 +69,16 @@
 		"subject": "Subject",
 		"test": "test",
 		"toBeSignedBy": "To be signed by",
+		"toRange": "to",
 		"update": "Update",
 		"updatePassword": "Update password",
 		"upperRequired": "One upper character required",
 		"validate": "Validate",
 		"validateAnnotation": "Validate the annotation",
+		"validateDocumentWithoutSignOrNote": "You are about to validate this document without signature or annotation!",
 		"wantDeleteSignatureOtherPage": "Do you want to delete the signature on the other pages?",
 		"wantSignOtherPage": "Do you want to sign the other pages?",
+		"wouldLikeConfirm": "Would you like to confirm?",
 		"wrongLoginPassword": "Wrong login or password",
 		"wrongPassword": "Wrong password",
 		"wsUser": "Web service user"
diff --git a/src/frontend/assets/i18n/fr.json b/src/frontend/assets/i18n/fr.json
index f83f078b63..f2075e28bc 100755
--- a/src/frontend/assets/i18n/fr.json
+++ b/src/frontend/assets/i18n/fr.json
@@ -1,10 +1,13 @@
 {
 	"lang": {
 		"administrations": "Administrations",
+		"annotateDocument": "Annoter ce document",
 		"annotationAdded": "Annotation ajoutée",
 		"annotationMode": "Mode de l'annotation",
 		"appleStylus": "Stylet Apple",
 		"areYouSure": "Êtes-vous sûr ?",
+		"atRange": "à",
+		"attention": "Attention",
 		"black": "Noir",
 		"blue": "Bleu",
 		"cancelPreviousNote": "Annuler la précédente note",
@@ -17,6 +20,8 @@
 		"deleteNoteAndSignature": "Effacer toutes les annotations et signatures ?",
 		"description": "Description",
 		"doc": "Doc",
+		"documentRefusedAs": "Document refusé en tant que :",
+		"documentValidateAs": "Document validé en tant que :",
 		"email": "Courriel",
 		"emittedBy": "Émis par",
 		"exitAnnotation": "Quitter l'annotation",
@@ -24,6 +29,7 @@
 		"forgotPassword": "Mot de passe oublié",
 		"free": "Libre",
 		"freeModeInfo": "Vous ne pourrez annoter les documents qu'avec le <b>stylet Apple</b>.<br />Cela a pour avantage de pouvoir poser la main sur la tablette sans perturber l'écriture.",
+		"fromRange": "De",
 		"historyUseInfo": "Vous ne pouvez pas utiliser les <b>{{countPwd}}</b> dernier(s) mot(s) de passe.",
 		"imageTooBig": "Image trop volumineuse (5mo max.)",
 		"informations": "Informations",
@@ -37,6 +43,7 @@
 		"noteAndSignatureDeleted": "Annotations / signatures supprimées du document",
 		"notifications": "Notifications",
 		"numberRequired": "1 chiffre requis",
+		"onRange": "le",
 		"open": "ouvrir",
 		"page": "page",
 		"password": "Mot de passe",
@@ -49,6 +56,8 @@
 		"receiveNotif": "Recevoir les notifications",
 		"red": "Rouge",
 		"reference": "Référence",
+		"refuseDocumentWithoutSignature": "Vous êtes sur le point de refuser ce document sans annotation !",
+		"rejectDocument": "Refuser ce document",
 		"renewalInfo": "Veuillez noter que ce nouveau mot de passe ne sera valide que <b>{{time}} jour(s)</b>. Passé ce délai, vous devrez en choisir un nouveau.",
 		"reply": "Répliquer",
 		"replySignatureAllPage": "Répliquer la signature sur toutes les pages",
@@ -60,13 +69,16 @@
 		"subject": "Objet",
 		"test": "test",
 		"toBeSignedBy": "À signer par",
+		"toRange": "à",
 		"update": "Modifier",
 		"updatePassword": "Modifier le mot de passe",
 		"upperRequired": "1 majuscule requise",
 		"validate": "Valider",
 		"validateAnnotation": "Valider l'annotation",
+		"validateDocumentWithoutSignOrNote": "Vous êtes sur le point de valider ce document sans signature ou annotation !",
 		"wantDeleteSignatureOtherPage": "Voulez-vous supprimer la signature sur les autres pages ?",
 		"wantSignOtherPage": "Voulez-vous apposer la signature sur les autres pages ?",
+		"wouldLikeConfirm": "Souhaitez-vous confirmer ?",
 		"wrongLoginPassword": "Mauvais identifiant ou mauvais mot de passe",
 		"wrongPassword": "Mauvais mot de passe",
 		"wsUser": "Utilisateur web service"
-- 
GitLab