Skip to content

Commit eafaaa4

Browse files
committed
front: add translation key for core errors, manage core errors by types instead of messages
1 parent 75e70e4 commit eafaaa4

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

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

+4-2
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",
@@ -104,8 +107,7 @@
104107
"not_found_in_tracks": "Missing track",
105108
"not_enough_path_items": "Missing parameters for pathfinding: Departure, Arrival, Rolling stock",
106109
"pathfinding_failure": "No path found",
107-
"rolling_stock_not_found": "Rolling stock not found",
108-
"the path goes over the same track multiple times": "The path goes over the same track multiple times"
110+
"rolling_stock_not_found": "Rolling stock not found"
109111
},
110112
"powerRestriction": "Power restriction code",
111113
"powerRestrictionExplanationText": "By default, the simulation will use the nominal power.",

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

+4-2
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",
@@ -104,8 +107,7 @@
104107
"not_found_in_tracks": "Voie manquante",
105108
"not_enough_path_items": "Éléments manquants pour la recherche : Origine, Destination, Matériel roulant",
106109
"pathfinding_failure": "Aucun chemin trouvé",
107-
"rolling_stock_not_found": "Matériel roulant non trouvé",
108-
"the path goes over the same track multiple times": "Le chemin emprunte plusieurs fois la même voie"
110+
"rolling_stock_not_found": "Matériel roulant non trouvé"
109111
},
110112
"pleaseWait": "Veuillez patientez…",
111113
"powerRestriction": "Code de restriction de puissance",

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

+6-1
Original file line numberDiff line numberDiff line change
@@ -368,9 +368,14 @@ export const usePathfinding = (
368368
}
369369
}
370370
} else if (pathfindingResult.failed_status === 'internal_error') {
371+
const translationKey = pathfindingResult.core_error.type.startsWith('core:')
372+
? pathfindingResult.core_error.type.replace('core:', '')
373+
: pathfindingResult.core_error.type;
371374
pathfindingDispatch({
372375
type: 'PATHFINDING_ERROR',
373-
message: t(`pathfindingErrors.${pathfindingResult.core_error.message}`),
376+
message: t(`coreErrors.${translationKey}`, {
377+
defaultValue: pathfindingResult.core_error.message,
378+
}),
374379
});
375380
} else {
376381
pathfindingDispatch({

0 commit comments

Comments
 (0)