Skip to content

Commit

Permalink
refactor: add some missing translations
Browse files Browse the repository at this point in the history
Reviewed-by: andriacap
  • Loading branch information
andriacap committed Oct 25, 2024
1 parent 659c3d8 commit 89089bb
Show file tree
Hide file tree
Showing 14 changed files with 303 additions and 14,148 deletions.
14,041 changes: 27 additions & 14,014 deletions admin/package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions admin/src/app/add-photo/add-photo.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

<ng-template #content let-modal>
<div class="modal-header">
<h5 class="modal-title">{{title}} </h5>
<h5 class="modal-title"> {{ isEdition ? ('ACTIONS.MODIFY' | translate: { article: ('ARTICLES.LA' | translate), varname: ('COMMONS.PICTURE' | translate) }) : ('ACTIONS.ADD' | translate: { article: ('ARTICLES.UNE' | translate), varname: ('COMMONS.PICTURE' | translate) }) }} </h5>
</div>
<form *ngIf="loadForm" [formGroup]="photoForm" (submit)="submitPhoto(photoForm)">
<div class="modal-body">
<button *ngIf="inputImage && currentUser.max_level_profil > 5" type="button" class="btn btn-outline-danger btn-delete"
(click)="openDeleteModal(photoModal)">
<i class="icon-bin delete-photo"></i>"{{ 'ACTIONS.DELETE' | translate: {article:('ARTICLES.LA' | translate), varname: ('COMMONS.PICTURE' | translate) } }}</button>
<i class="icon-bin delete-photo"></i>{{ 'ACTIONS.DELETE' | translate: {article:('ARTICLES.LA' | translate), varname: ('COMMONS.PICTURE' | translate) } }}</button>
<div class="inner-checkbox form-group">
<div class="label">{{ 'ACTIONS.PUBLISH' | translate: {article:('ARTICLES.LA' | translate), varname: ('COMMONS.PICTURE' | translate) } }} :</div>
<label class="switch ">
Expand Down Expand Up @@ -72,7 +72,7 @@ <h5 class="modal-title">{{title}} </h5>
</div>
<div class="modal-footer">
<button type="button" class="red-btn" style="margin-right: 10px" (click)="onCancel()">{{'BUTTONS.CANCEL' | translate}}</button>
<button type="submit" class="green-btn" [disabled]="disableButton">{{btn_text}}</button>
<button type="submit" class="green-btn" [disabled]="disableButton">{{ isEdition ? ('ACTIONS.MODIFY_DEFAULT' | translate) : ('BUTTONS.ADD' | translate) }}</button>
</div>
</form>
</ng-template>
Expand All @@ -86,6 +86,6 @@ <h5 class="modal-title"><i class="icon-bin"></i></h5>
</div>
<div class="modal-footer">
<button type="button" class="cancel-btn" style="margin-right: 10px" (click)="cancelDelete()">{{'BUTTONS.CANCEL' | translate}}</button>
<button type="button" class="green-btn" (click)="deletePhoto()">OUI</button>
<button type="button" class="green-btn" (click)="deletePhoto()">{{ 'COMMONS.YES' | translate}}</button>
</div>
</ng-template>
40 changes: 25 additions & 15 deletions admin/src/app/add-photo/add-photo.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { ToastrService } from 'ngx-toastr';
import { forkJoin } from 'rxjs';
import { AuthService } from '../services/auth.service';
import { NgxSpinnerService } from 'ngx-spinner';
import { TranslateService } from '@ngx-translate/core';

const I18N_VALUES = {
fr: {
Expand Down Expand Up @@ -88,8 +89,7 @@ export class AddPhotoComponent implements OnInit {
imageLaoded = false;
private modalRef: NgbModalRef;
disableButton = false;
btn_text = 'ACTIONS.ADD';
title = "{{ 'ACTIONS.ADD' | translate: {article:('ARTICLES.UNE' | translate), varname: ('COMMONS.PICTURE' | translate) } }}";
isEdition = false;
alert: any;
@Output() photoModal = new EventEmitter();
@Input() inputImage = null;
Expand All @@ -104,7 +104,8 @@ export class AddPhotoComponent implements OnInit {
public calendar: NgbCalendar,
datePickerConfig: NgbDatepickerConfig,
private authService: AuthService,
private spinner: NgxSpinnerService
private spinner: NgxSpinnerService,
private translate: TranslateService
) {
datePickerConfig.minDate = { year: 1800, month: 1, day: 1 };
datePickerConfig.maxDate = { year: 2200, month: 12, day: 31 };
Expand All @@ -113,7 +114,6 @@ export class AddPhotoComponent implements OnInit {

ngOnInit() {
this.currentUser = this.authService.currentUser;

if (this.licences) {
this.onInitData();
} else {
Expand All @@ -126,8 +126,7 @@ export class AddPhotoComponent implements OnInit {

onInitData() {
if (this.inputImage) {
this.title = 'Modifier la photo';
this.btn_text = 'Modifier';
this.isEdition = true;
this.updateForm();
} else {
this.initForm();
Expand Down Expand Up @@ -233,7 +232,10 @@ export class AddPhotoComponent implements OnInit {
console.log('invalid form');
this.disableButton = false;
if (!this.imageName) {
this.alert = 'Veuillez importer une photo ';
this.translate.get('INFO_MESSAGE.NO_PICTURE').subscribe((message: string) => {
this.alert = message;
})

}
}
}
Expand Down Expand Up @@ -270,13 +272,17 @@ export class AddPhotoComponent implements OnInit {
this.modalRef.close();
if (err.status === 403) {
this.router.navigate(['']);
this.toastr.error('votre session est expirée', '', {
positionClass: 'toast-bottom-right',
});
this.translate.get('ERRORS.EXPIRED_SESSION').subscribe((res: string) => {
this.toastr.error(res, '', {
positionClass: 'toast-bottom-right',
});
})
} else
this.toastr.error('Une erreur est survenue sur le serveur.', '', {
this.translate.get('ERRORS.SERVER_ERROR').subscribe((res: string) => {
this.toastr.error(res, '', {
positionClass: 'toast-bottom-right',
});
})
}
);
}
Expand Down Expand Up @@ -304,13 +310,17 @@ export class AddPhotoComponent implements OnInit {
this.modalRef.close();
if (err.status === 403) {
this.router.navigate(['']);
this.toastr.error('votre session est expirée', '', {
positionClass: 'toast-bottom-right',
});
this.translate.get('ERRORS.EXPIRED_SESSION').subscribe((res: string) => {
this.toastr.error(res, '', {
positionClass: 'toast-bottom-right',
});
})
} else
this.toastr.error('Une erreur est survenue sur le serveur.', '', {
this.translate.get('ERRORS.SERVER_ERROR').subscribe((res: string) => {
this.toastr.error(res, '', {
positionClass: 'toast-bottom-right',
});
})
},
() => {
this.photoModal.emit(this.inputImage.t_site);
Expand Down
145 changes: 92 additions & 53 deletions admin/src/app/add-site/add-site.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import { ObservatoriesService } from '../services/observatories.service';
import { ObservatoryType } from '../types';
import { DbConfService, IDBConf } from '../services/dbconf.service';
import { ToolbarService, LinkService, ImageService, HtmlEditorService } from '@syncfusion/ej2-angular-richtexteditor';
import { TranslateService } from '@ngx-translate/core';
import { switchMap, tap } from 'rxjs/operators';

@Component({
selector: 'app-add-site',
Expand Down Expand Up @@ -109,7 +111,8 @@ export class AddSiteComponent implements OnInit, OnDestroy {
private modalService: NgbModal,
private authService: AuthService,
private spinner: NgxSpinnerService,
private dbConfSrv: DbConfService
private dbConfSrv: DbConfService,
private translate: TranslateService
) {}

ngOnInit() {
Expand Down Expand Up @@ -182,7 +185,9 @@ export class AddSiteComponent implements OnInit, OnDestroy {
container.innerHTML =
'<i style="line-height: unset" class="icon-full_screen"> </i>';
container.style.backgroundColor = 'white';
container.title = 'Recentrer la carte';
this.translate.get('INFO_MESSAGE.RECENTER_MAP').subscribe((translatedMessage) => {
container.title = translatedMessage;
})
container.onclick = () => {
this.center = latLng(this.site.geom);
this.zoom = 10;
Expand Down Expand Up @@ -307,7 +312,9 @@ export class AddSiteComponent implements OnInit, OnDestroy {
this.sitesService.addSite(this.siteJson).subscribe(
(site) => {
// tslint:disable-next-line:quotemark
this.toast_msg = "Point d'observation ajouté avec succès";
this.translate.get("INFO_MESSAGE.SUCESS_ADDED_SITE").subscribe((translatedMessage: string) => {
this.toast_msg = translatedMessage;
})
this.addThemes(
Number(site.id_site),
siteForm.value.id_theme,
Expand All @@ -320,14 +327,17 @@ export class AddSiteComponent implements OnInit, OnDestroy {
this.edit_btn = true;
if (err.status === 403) {
this.router.navigate(['']);
this.toastr.error('votre session est expirée', '', {
positionClass: 'toast-bottom-right',
});
} else {
this.toastr.error('Une erreur est survenue sur le serveur.', '', {
positionClass: 'toast-bottom-right',
});
}
this.translate.get('ERRORS.EXPIRED_SESSION').subscribe((translatedMessage: string) => {
this.toastr.error(translatedMessage, '', {
positionClass: 'toast-bottom-right',
});
})
} else
this.translate.get('ERRORS.SERVER_ERROR').subscribe((translatedMessage: string) => {
this.toastr.error(translatedMessage, '', {
positionClass: 'toast-bottom-right',
});
})
}
);
} else {
Expand Down Expand Up @@ -386,13 +396,17 @@ export class AddSiteComponent implements OnInit, OnDestroy {
this.edit_btn = true;
this.setAlert(err.error.image);
} else if (err.status === 403) {
this.router.navigate(['']);
this.toastr.error('votre session est expirée', '', {
positionClass: 'toast-bottom-right',
this.translate.get('ERRORS.SESSION_EXPIRED').subscribe((translatedMessage: string) => {
this.router.navigate(['']);
this.toastr.error(translatedMessage, '', {
positionClass: 'toast-bottom-right',
});
});
} else {
this.toastr.error('Une erreur est survenue sur le serveur.', '', {
positionClass: 'toast-bottom-right',
this.translate.get('ERRORS.SERVER_ERROR').subscribe((translatedMessage: string) => {
this.toastr.error(translatedMessage, '', {
positionClass: 'toast-bottom-right',
});
});
}
},
Expand Down Expand Up @@ -459,23 +473,31 @@ export class AddSiteComponent implements OnInit, OnDestroy {
(err) => {
this.spinner.hide();
if (err.status === 403) {
this.router.navigate(['']);
this.toastr.error('votre session est expirée', '', {
positionClass: 'toast-bottom-right',
this.translate.get('ERRORS.SESSION_EXPIRED').subscribe((message: string) => {
this.router.navigate(['']);
this.toastr.error(message, '', {
positionClass: 'toast-bottom-right',
});
});
} else
this.toastr.error('Une erreur est survenue sur le serveur.', '', {
positionClass: 'toast-bottom-right',
} else {
this.translate.get('ERRORS.SERVER_ERROR').subscribe((message: string) => {
this.toastr.error(message, '', {
positionClass: 'toast-bottom-right',
});
});
}
}
);
}

setAlert(message) {
this.alert = {
type: 'danger',
message: 'La ' + message + ' existe déjà',
};
setAlert(message: string) {
this.translate.get('ALERTS.ITEM_EXISTS').subscribe((translatedMessage: string) => {
// Concaténer le message traduit avec la variable non traduite
this.alert = {
type: 'danger',
message: `${translatedMessage.replace('{{ item }}', message)}`,
};
});
}

getSite(id_site) {
Expand All @@ -496,9 +518,10 @@ export class AddSiteComponent implements OnInit, OnDestroy {
});
},
(err) => {
console.log('err', err);
this.toastr.error('Une erreur est survenue sur le serveur.', '', {
positionClass: 'toast-bottom-right',
this.translate.get('ERRORS.SERVER_ERROR').subscribe((res: string) => {
this.toastr.error(res, '', {
positionClass: 'toast-bottom-right',
});
});
},
() => {
Expand Down Expand Up @@ -611,27 +634,38 @@ export class AddSiteComponent implements OnInit, OnDestroy {
this.new_photos.push(photo);
}
});
this.sitesService.updateSite(siteJson).subscribe(
(res) => {
// tslint:disable-next-line:quotemark
this.toast_msg = "Point d'observation mis à jour";
this.edit_btn_text = 'Éditer';
if (this.deleted_photos.length > 0) {
this.sitesService.deletePhotos(this.deleted_photos).subscribe();
}
this.addThemes(Number(this.id_site), themes, sthemes, false);
},
this.sitesService.updateSite(siteJson).pipe(
switchMap((res) => {
return this.translate.get(['INFO_MESSAGE.SUCCESS_UPDATED_SITE', 'BUTTONS.EDIT']).pipe(
tap(translations => {
this.toast_msg = translations['INFO_MESSAGE.SUCCESS_UPDATED_SITE'];
this.edit_btn_text = translations['BUTTONS.EDIT'];

if (this.deleted_photos.length > 0) {
this.sitesService.deletePhotos(this.deleted_photos).subscribe();
}
this.addThemes(Number(this.id_site), themes, sthemes, false);
})
);
})
).subscribe(
() => {}, // Success handler (déjà géré dans `tap`)
(err) => {
this.spinner.hide();
if (err.status === 403) {
this.router.navigate(['']);
this.toastr.error('votre session est expirée', '', {
positionClass: 'toast-bottom-right',
this.translate.get('ERRORS.SESSION_EXPIRED').subscribe((message: string) => {
this.router.navigate(['']);
this.toastr.error(message, '', {
positionClass: 'toast-bottom-right',
});
});
} else
this.toastr.error('Une erreur est survenue sur le serveur.', '', {
positionClass: 'toast-bottom-right',
} else {
this.translate.get('ERRORS.SERVER_ERROR').subscribe((message: string) => {
this.toastr.error(message, '', {
positionClass: 'toast-bottom-right',
});
});
}
}
);
}
Expand All @@ -640,7 +674,7 @@ export class AddSiteComponent implements OnInit, OnDestroy {
this.edit_btn = !this.edit_btn;
if (!this.edit_btn) {
this.map.removeControl(this.drawControl);
this.edit_btn_text = 'Éditer';
this.edit_btn_text = 'BUTTONS.EDIT';
this.patchForm();
this.alert = null;
this.photos = this.initPhotos;
Expand Down Expand Up @@ -697,14 +731,19 @@ export class AddSiteComponent implements OnInit, OnDestroy {
},
(err) => {
if (err.status === 403) {
this.router.navigate(['']);
this.toastr.error('votre session est expirée', '', {
positionClass: 'toast-bottom-right',
this.translate.get('ERRORS.SESSION_EXPIRED').subscribe((message: string) => {
this.router.navigate(['']);
this.toastr.error(message, '', {
positionClass: 'toast-bottom-right',
});
});
} else
this.toastr.error('Une erreur est survenue sur le serveur.', '', {
positionClass: 'toast-bottom-right',
} else {
this.translate.get('ERRORS.SERVER_ERROR').subscribe((message: string) => {
this.toastr.error(message, '', {
positionClass: 'toast-bottom-right',
});
});
}
}
);
this.modalRef.close();
Expand Down
Loading

0 comments on commit 89089bb

Please sign in to comment.