From eb40dabc98183a507eb15f1ea1c74eab79820bea Mon Sep 17 00:00:00 2001 From: romainvalls Date: Fri, 15 Nov 2024 14:19:00 +0100 Subject: [PATCH] front: fix translations for pathfinding error in itinerary Signed-off-by: romainvalls --- .../en/operationalStudies/manageTrainSchedule.json | 3 +++ .../fr/operationalStudies/manageTrainSchedule.json | 3 +++ front/src/modules/pathfinding/hooks/usePathfinding.ts | 11 ++++++++--- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/front/public/locales/en/operationalStudies/manageTrainSchedule.json b/front/public/locales/en/operationalStudies/manageTrainSchedule.json index ef6e0947af7..6b71204c39f 100644 --- a/front/public/locales/en/operationalStudies/manageTrainSchedule.json +++ b/front/public/locales/en/operationalStudies/manageTrainSchedule.json @@ -9,6 +9,9 @@ "cancelPathfinding": "Cancel", "chooseOnMap": "Choose on the map", "composition": "Composition", + "coreErrors": { + "path_with_repeated_tracks": "The path goes over the same track multiple times" + }, "deleteVias": "Delete steps", "deleteRoute": "Delete the route", "destination": "Destination", diff --git a/front/public/locales/fr/operationalStudies/manageTrainSchedule.json b/front/public/locales/fr/operationalStudies/manageTrainSchedule.json index c7d1eac9065..80ba3657a5c 100644 --- a/front/public/locales/fr/operationalStudies/manageTrainSchedule.json +++ b/front/public/locales/fr/operationalStudies/manageTrainSchedule.json @@ -9,6 +9,9 @@ "cancelPathfinding": "Annuler", "chooseOnMap": "Choisir sur la carte", "composition": "Composition", + "coreErrors": { + "path_with_repeated_tracks": "Le chemin emprunte plusieurs fois la même voie" + }, "deleteRoute": "Supprimer l'itinéraire", "deleteVias": "Supprimer les étapes", "destination": "Destination", diff --git a/front/src/modules/pathfinding/hooks/usePathfinding.ts b/front/src/modules/pathfinding/hooks/usePathfinding.ts index 0d71aa17118..fee63419ff0 100644 --- a/front/src/modules/pathfinding/hooks/usePathfinding.ts +++ b/front/src/modules/pathfinding/hooks/usePathfinding.ts @@ -365,19 +365,24 @@ export const usePathfinding = ( } else { pathfindingDispatch({ type: 'PATHFINDING_INCOMPATIBLE_CONSTRAINTS', - message: `pathfindingErrors.${pathfindingResult.error_type}`, + message: t(`pathfindingErrors.${pathfindingResult.error_type}`), }); } } } else if (pathfindingResult.failed_status === 'internal_error') { + const translationKey = pathfindingResult.core_error.type.startsWith('core:') + ? pathfindingResult.core_error.type.replace('core:', '') + : pathfindingResult.core_error.type; pathfindingDispatch({ type: 'PATHFINDING_ERROR', - message: `pathfindingErrors.${pathfindingResult.core_error.message}`, + message: t(`coreErrors.${translationKey}`, { + defaultValue: pathfindingResult.core_error.message, + }), }); } else { pathfindingDispatch({ type: 'PATHFINDING_ERROR', - message: `pathfindingErrors.${pathfindingResult.error_type}`, + message: t(`pathfindingErrors.${pathfindingResult.error_type}`), }); } } catch (e) {