Skip to content

Commit b817ae6

Browse files
committed
front: fix translations for pathfinding error in itinerary
1 parent 36eb346 commit b817ae6

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

front/public/locales/en/operationalStudies/manageTrainSchedule.json

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
"cancelPathfinding": "Cancel",
1010
"chooseOnMap": "Choose on the map",
1111
"composition": "Composition",
12+
"coreErrors": {
13+
"path_with_repeated_tracks": "The path goes over the same track multiple times"
14+
},
1215
"deleteVias": "Delete steps",
1316
"deleteRoute": "Delete the route",
1417
"destination": "Destination",

front/public/locales/fr/operationalStudies/manageTrainSchedule.json

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
"cancelPathfinding": "Annuler",
1010
"chooseOnMap": "Choisir sur la carte",
1111
"composition": "Composition",
12+
"coreErrors": {
13+
"path_with_repeated_tracks": "Le chemin emprunte plusieurs fois la même voie"
14+
},
1215
"deleteRoute": "Supprimer l'itinéraire",
1316
"deleteVias": "Supprimer les étapes",
1417
"destination": "Destination",

front/src/modules/pathfinding/hooks/usePathfinding.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -365,19 +365,24 @@ export const usePathfinding = (
365365
} else {
366366
pathfindingDispatch({
367367
type: 'PATHFINDING_INCOMPATIBLE_CONSTRAINTS',
368-
message: `pathfindingErrors.${pathfindingResult.error_type}`,
368+
message: t(`pathfindingErrors.${pathfindingResult.error_type}`),
369369
});
370370
}
371371
}
372372
} else if (pathfindingResult.failed_status === 'internal_error') {
373+
const translationKey = pathfindingResult.core_error.type.startsWith('core:')
374+
? pathfindingResult.core_error.type.replace('core:', '')
375+
: pathfindingResult.core_error.type;
373376
pathfindingDispatch({
374377
type: 'PATHFINDING_ERROR',
375-
message: `pathfindingErrors.${pathfindingResult.core_error.message}`,
378+
message: t(`coreErrors.${translationKey}`, {
379+
defaultValue: pathfindingResult.core_error.message,
380+
}),
376381
});
377382
} else {
378383
pathfindingDispatch({
379384
type: 'PATHFINDING_ERROR',
380-
message: `pathfindingErrors.${pathfindingResult.error_type}`,
385+
message: t(`pathfindingErrors.${pathfindingResult.error_type}`),
381386
});
382387
}
383388
} catch (e) {

0 commit comments

Comments
 (0)