From cf04b93cfcd596bed73d1716c543d808fc17e2e9 Mon Sep 17 00:00:00 2001 From: MadhuMosip Date: Wed, 13 Mar 2024 17:08:05 +0530 Subject: [PATCH] MOSIP-22207 Message displayed should be properly according to logged in language in entire PMP UI Signed-off-by: MadhuMosip --- .../src/app/core/services/common.service.ts | 11 +++++--- .../cert-upload/cert-upload.component.ts | 23 +++++++++------- .../shared/dialog/dialog.component.html | 2 +- .../mater-data-common-body.component.ts | 26 ++++++++++++------- .../app/shared/dialog/dialog.component.html | 2 +- pmp-ui/src/assets/i18n/ara.json | 19 +++++++++++--- pmp-ui/src/assets/i18n/eng.json | 21 ++++++++++++--- pmp-ui/src/assets/i18n/fra.json | 19 +++++++++++--- pmp-ui/src/assets/i18n/hin.json | 19 +++++++++++--- pmp-ui/src/assets/i18n/kan.json | 19 +++++++++++--- pmp-ui/src/assets/i18n/tam.json | 21 ++++++++++++--- 11 files changed, 139 insertions(+), 43 deletions(-) diff --git a/pmp-ui/src/app/core/services/common.service.ts b/pmp-ui/src/app/core/services/common.service.ts index cdcfeb87c..56b0dc06d 100644 --- a/pmp-ui/src/app/core/services/common.service.ts +++ b/pmp-ui/src/app/core/services/common.service.ts @@ -35,6 +35,7 @@ export class CommonService { approved : string = "Approved"; rejected : string = "Rejected"; descr: string; + langJson:any; constructor( public router: Router, public dataService: DataStorageService, @@ -49,6 +50,7 @@ export class CommonService { .subscribe(result => { this.actionMessages = result.actionMessages; this.serverMessages = result.serverError; + this.langJson = result; }); } @@ -248,7 +250,8 @@ export class CommonService { this.dataService.updateDetails(mapping, request).subscribe( response => { if (!response.errors || response.errors.length === 0) { - this.createMessage('success', callingFunction, response.response); + let successMessage = this.langJson.successMessages.sbi[callingFunction] + this.createMessage('success', callingFunction, successMessage); this.router.navigateByUrl(this.router.url); } else { this.createMessage('error', callingFunction, response.errors); @@ -325,14 +328,14 @@ export class CommonService { } viewCertificate(data: any){ - this.dataService.viewCertificate(data).subscribe(response =>{ + this.dataService.viewCertificate(data).subscribe(response =>{ if(response.errors.length <= 0) { this.showCertificate('activate', response.response.certificateData); } else { let obj = {}; obj = { - title: 'Certificate', - message: response.errors[0].message, + title: this.langJson.generickeys.certificate, + message: this.serverMessages[response.errors[0].errorCode], btnTxt: 'Ok' }; this.showCertificateDetails(obj); diff --git a/pmp-ui/src/app/features/resources/cert-upload/cert-upload.component.ts b/pmp-ui/src/app/features/resources/cert-upload/cert-upload.component.ts index 0c66bce7a..047bd14d9 100644 --- a/pmp-ui/src/app/features/resources/cert-upload/cert-upload.component.ts +++ b/pmp-ui/src/app/features/resources/cert-upload/cert-upload.component.ts @@ -36,6 +36,7 @@ export class CertUploadComponent { fetchRequest = {} as CenterRequest; uploadcertificate:any; files: any[] = []; + langJson:any; constructor( public formBuilder: FormBuilder, @@ -61,9 +62,11 @@ export class CertUploadComponent { this.primaryLangCode = this.headerService.getlanguageCode(); this.translate .getTranslation(this.primaryLangCode) - .subscribe(response => ( - this.uploadcertificate = response.uploadcertificate, - this.popupMessages = response.genericerror)); + .subscribe(response => { + this.uploadcertificate = response.uploadcertificate; + this.popupMessages = response.genericerror; + this.langJson = response; + }); this.activatedRoute.params.subscribe(response => { this.id = response.id; this.masterdataType = response.type; @@ -100,7 +103,7 @@ export class CertUploadComponent { }; fileReader.readAsText(file); }else{ - self.showErrorPopup("pem or cer format file only supported."); + self.showErrorPopup(this.uploadcertificate.supportedDoc); } } @@ -185,7 +188,7 @@ export class CertUploadComponent { width: '550px', data: { case: 'MESSAGE', - title: 'Error', + title: this.langJson.generickeys.error, message: message, btnTxt: 'Ok' }, @@ -200,16 +203,16 @@ export class CertUploadComponent { if(response.errors.length > 0){ data = { case: 'MESSAGE', - title: "Failure !", - message: response.errors[0].message, + title: this.langJson.generickeys.failure, + message: this.langJson.serverError[response.errors[0].errorCode], btnTxt: "DONE" }; }else{ data = { case: 'MESSAGE', - title: "Success", - message: response.response.status, - btnTxt: "DONE" + title: this.langJson.generickeys.success, + message: this.langJson.generickeys.updatedSuccessfully, + btnTxt: this.langJson.generickeys.ok }; } const dialogRef = self.dialog.open(DialogComponent, { diff --git a/pmp-ui/src/app/features/resources/shared/dialog/dialog.component.html b/pmp-ui/src/app/features/resources/shared/dialog/dialog.component.html index b1f523982..a3fe645fc 100644 --- a/pmp-ui/src/app/features/resources/shared/dialog/dialog.component.html +++ b/pmp-ui/src/app/features/resources/shared/dialog/dialog.component.html @@ -205,7 +205,7 @@

{{ "filters.titleTxt" | translate }}

height="45px" width="45px" class="success-img" - *ngIf="input.title === 'Success' || input.title === 'النجاح' || input.title === 'Succès'|| input.title === 'सफलता' || input.title === 'ಯಶಸ್ಸು' || input.title === 'வெற்றி'" /> + *ngIf="input.title === 'Success' || input.title === 'خطأ' || input.title === 'Succès'|| input.title === 'सफलता' || input.title === 'ಯಶಸ್ಸು' || input.title === 'வெற்றி'" /> 0){ - this.showErrorPopup(response.errors[0].message); + this.showErrorPopup(errorMessage); }else{ this.showErrorPopup(response.errors.message); } } }); - }else{ + }else{ let request = new RequestModel( "", null, @@ -662,9 +663,16 @@ export class MaterDataCommonBodyComponent implements OnInit { this.changePage(); }); }else { - if(response.errors.length > 0){ - this.showErrorPopup(response.errors[0].message); + let errorMessage + let policyName = response.errors[0].message.split(':')[1] + if(policyName){ + errorMessage = this.popupMessages.serverError[response.errors[0].errorCode] + policyName }else{ + errorMessage = this.popupMessages.serverError[response.errors[0].errorCode] + } + if(response.errors.length > 0){ + this.showErrorPopup(errorMessage); + }else{ this.showErrorPopup(response.errors.message); } } @@ -695,7 +703,7 @@ export class MaterDataCommonBodyComponent implements OnInit { width: '550px', data: { case: 'MESSAGE', - title: 'Success', + title: this.popupMessages.generickeys.success, message: message, btnTxt: this.popupMessages.generickeys.ok } @@ -709,7 +717,7 @@ export class MaterDataCommonBodyComponent implements OnInit { width: '550px', data: { case: 'MESSAGE', - title: 'Error', + title: this.popupMessages.generickeys.error, message: message, btnTxt: this.popupMessages.generickeys.ok }, diff --git a/pmp-ui/src/app/shared/dialog/dialog.component.html b/pmp-ui/src/app/shared/dialog/dialog.component.html index 5414fdb51..136b29cc9 100644 --- a/pmp-ui/src/app/shared/dialog/dialog.component.html +++ b/pmp-ui/src/app/shared/dialog/dialog.component.html @@ -253,7 +253,7 @@

{{ "filters.titleTxt" | translate }}

height="45px" width="45px" class="success-img" - *ngIf="input.title === 'Success' || input.title === 'النجاح' || input.title === 'Succès'|| input.title === 'सफलता' || input.title === 'ಯಶಸ್ಸು' || input.title === 'வெற்றி'" /> + *ngIf="input.title === 'Success' || input.title === 'نجاح' || input.title === 'Succès'|| input.title === 'सफलता' || input.title === 'ಯಶಸ್ಸು' || input.title === 'வெற்றி'" />