Skip to content

Commit

Permalink
feat: add translations on charts
Browse files Browse the repository at this point in the history
  • Loading branch information
FerranAD committed Dec 13, 2023
1 parent f262d4d commit 617b44a
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import {OccupationService} from '../../services/occupation/occupation.service';
import {RefugeReservationService} from "../../services/reservations/refuge-reservation.service";
import {WeekReservations} from "../../schemas/reservations/reservation";
import {toShortString} from "../../schemas/night/night";
import {TranslateService} from "@ngx-translate/core";
import {AlertController} from "@ionic/angular";
import {Router} from "@angular/router";

@Component({
selector: 'app-reservations-chart',
Expand Down Expand Up @@ -40,7 +43,7 @@ export class ReservationsChartComponent implements OnInit {
};
xAxisTickFormatting = (value: string) => {
if (value === this.today) {
return 'Today';
return this.translateService.instant('REFUGE.OCCUPATION.TODAY');
}
return value;
};
Expand All @@ -49,6 +52,9 @@ export class ReservationsChartComponent implements OnInit {
private changeDetectorRef: ChangeDetectorRef,
private occupationService: OccupationService,
private reservationService: RefugeReservationService,
private translateService: TranslateService,
private alertController: AlertController,
private router: Router,
) {
}

Expand Down Expand Up @@ -80,12 +86,28 @@ export class ReservationsChartComponent implements OnInit {
this.formatChartReservations();
console.log(this.formattedChartReservations)
},
error: (err) => {
console.log("error" + err);
}
error: () => this.handleClientError().then(),
});
}

private async handleClientError() {
const alert = await this.alertController.create({
header: this.translateService.instant('HOME.CLIENT_ERROR.HEADER'),
subHeader: this.translateService.instant('HOME.CLIENT_ERROR.SUBHEADER'),
message: this.translateService.instant('HOME.CLIENT_ERROR.MESSAGE'),
buttons: [
{
text: this.translateService.instant('HOME.CLIENT_ERROR.OKAY_BUTTON'),
handler: () => {
this.alertController.dismiss().then();
this.router.navigate(['/home']).then();
},
},
],
});
return await alert.present();
}

previousWeek() {
this.offset--;
this.updateChart()
Expand Down
3 changes: 2 additions & 1 deletion app/src/assets/i18n/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@
"OCCUPATION": {
"HISTORIAL": "Històric d'ocupació",
"XLABEL": "Dia",
"YLABEL": "Reserves"
"YLABEL": "Reserves",
"TODAY": "Avui"
}
},
"RESERVATIONS": {
Expand Down
3 changes: 2 additions & 1 deletion app/src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@
"OCCUPATION": {
"HISTORIAL": "Occupation historic",
"XLABEL": "Day",
"YLABEL": "Reservations"
"YLABEL": "Reservations",
"TODAY": "Today"
}
},
"RESERVATIONS": {
Expand Down
3 changes: 2 additions & 1 deletion app/src/assets/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@
"OCCUPATION": {
"HISTORIAL": "Histórico de ocupación",
"XLABEL": "Día",
"YLABEL": "Reservas"
"YLABEL": "Reservas",
"TODAY": "Hoy"
}
},
"RESERVATIONS": {
Expand Down
3 changes: 2 additions & 1 deletion app/src/assets/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@
"OCCUPATION": {
"HISTORIAL": "Historique d'occupation",
"XLABEL": "Jour",
"YLABEL": "Réservations"
"YLABEL": "Réservations",
"TODAY": "Aujourd'hui"
}
},
"RESERVATIONS": {
Expand Down

0 comments on commit 617b44a

Please sign in to comment.