Skip to content

Commit caebc1e

Browse files
committed
Translate toaster messages
1 parent 53b3d72 commit caebc1e

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

projects/train-platform/src/assets/i18n/de.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
"booking": {
1111
"reserveSeatQuestion": "Möchten Sie einen Sitzplatz reservieren?",
1212
"firstClassQuestion": "Möchten Sie in der ersten Klasse sitzen?",
13-
"bookAction": "Buchen"
13+
"bookAction": "Buchen",
14+
"confirmation": "Reise gebucht!",
15+
"error": "Reise konnte nicht gebucht werden!"
1416
},
1517
"journey": {
1618
"bookAction": "Buchen"

projects/train-platform/src/assets/i18n/en.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
"booking": {
1111
"reserveSeatQuestion": "Do you want to reserve a seat?",
1212
"firstClassQuestion": "Do you want to sit in first class?",
13-
"bookAction": "Book"
13+
"bookAction": "Book",
14+
"confirmation": "Booked a journey!",
15+
"error": "Journey could not be booked!"
1416
},
1517
"journey": {
1618
"bookAction": "Book"

projects/train-platform/src/booking/booking/booking.component.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Component } from '@angular/core';
22
import { ActivatedRoute } from '@angular/router';
33
import { HotToastService } from '@ngneat/hot-toast';
4+
import { TranslateService } from '@ngx-translate/core';
45
import { BookingService } from '../booking.service';
56

67
@Component({
@@ -15,7 +16,8 @@ export class BookingComponent {
1516
constructor(
1617
private bookingService: BookingService,
1718
private route: ActivatedRoute,
18-
private toast: HotToastService
19+
private toast: HotToastService,
20+
private translateService: TranslateService
1921
) {}
2022

2123
book(): void {
@@ -26,15 +28,12 @@ export class BookingComponent {
2628
})
2729
.subscribe(
2830
() => {
29-
this.toast
30-
.success(`Booked a journey with the id ${this.route.snapshot.params.journeyId}!
31-
Reserved Seat? ${this.reserveSeat}
32-
First Class? ${this.firstClass}`);
31+
this.toast.success(
32+
this.translateService.instant('booking.confirmation')
33+
);
3334
},
3435
() => {
35-
this.toast.error(
36-
`Journey with the id ${this.route.snapshot.params.journeyId} could not be booked!`
37-
);
36+
this.toast.error(this.translateService.instant('booking.error'));
3837
}
3938
);
4039
}

0 commit comments

Comments
 (0)