From 59b064fdb9b5d398a95c89a71e4b58042e67270e Mon Sep 17 00:00:00 2001
From: SharglutDev
Date: Mon, 24 Feb 2025 11:54:35 +0100
Subject: [PATCH] front: refacto some manage train schedule translations
Signed-off-by: SharglutDev
---
.../en/operationalStudies/manageTrainSchedule.json | 9 ++-------
.../fr/operationalStudies/manageTrainSchedule.json | 9 ++-------
.../ManageTrainSchedule/PacedTrainSettings.tsx | 4 ++--
.../ManageTrainSchedule/TrainAddingSettings.tsx | 6 +++---
.../ManageTrainSchedule/helpers/checkCurrentConfig.ts | 11 ++++++++---
5 files changed, 17 insertions(+), 22 deletions(-)
diff --git a/front/public/locales/en/operationalStudies/manageTrainSchedule.json b/front/public/locales/en/operationalStudies/manageTrainSchedule.json
index 50dd78cfcc4..a68e1d950e3 100644
--- a/front/public/locales/en/operationalStudies/manageTrainSchedule.json
+++ b/front/public/locales/en/operationalStudies/manageTrainSchedule.json
@@ -25,10 +25,7 @@
"invalidInitialSpeed": "The initial speed must be rounded to the nearest tenth",
"mandatoryField": "Required field",
"nameLengthLimit": "The name must not exceed 128 characters",
- "noCadence": "The cadence must be must be greater than 0",
- "noCadenceInput": "Must be > 0",
"noDelta": "The headway between two trains has to be at least one minute.",
- "noDeltaInput": "Must be > 0",
"noDepartureTime": "Please enter a departure time",
"noDestination": "The destination is not defined",
"noName": "Please choose a name for the train",
@@ -37,17 +34,15 @@
"noPathfinding": "Please relaunch the pathfinding",
"noRollingStock": "The train composition is missing",
"noSpeedLimitByTag": "Please choose a composition code",
- "noTimeRangeDuration": "The time range duration must be greater than 0",
- "noTimeRangeDurationInput": "Must be > 0",
"noTimetable": "Please choose or create a timetable",
"noTrainCount": "The quantity of requested trains must be greater than zero",
- "noTrainCountInput": "Must be > 0",
"noTrainStep": "The increment step of the train must be greater than zero",
- "noTrainStepInput": "Must be > 0",
"originTimeOutsideWindow": "Departure date must be between {{low}} and {{high}}",
"requiredField": "Required field.",
"softErrorInfra": "The application is unavailable, a server error has occurred, please try again later.",
"The requested train couldn't reach its destination": "The train cannot reach its destination",
+ "tooLowInput": "Must be > 0",
+ "tooLowValue": "The {{value}} must be greater than 0",
"trainScheduleTitle": "An error has occurred",
"unableToDeleteTrain": "Impossible to delete the train",
"unableToDuplicateTrain": "Impossible to duplicate the train",
diff --git a/front/public/locales/fr/operationalStudies/manageTrainSchedule.json b/front/public/locales/fr/operationalStudies/manageTrainSchedule.json
index 12e538cef87..af3d1062557 100644
--- a/front/public/locales/fr/operationalStudies/manageTrainSchedule.json
+++ b/front/public/locales/fr/operationalStudies/manageTrainSchedule.json
@@ -25,10 +25,7 @@
"invalidInitialSpeed": "La vitesse initiale doit être arrondie au dixième",
"mandatoryField": "Champ obligatoire",
"nameLengthLimit": "Le nom ne doit pas dépasser 128 caractères",
- "noCadence": "La cadence doit être supérieure à 0",
- "noCadenceInput": "Doit être > 0",
"noDelta": "L'intervalle entre deux trains doit être d'au moins une minute",
- "noDeltaInput": "Doit être > 0",
"noDepartureTime": "Veuillez renseigner une heure de départ",
"noDestination": "La destination n'est pas définie",
"noName": "Veuillez choisir un nom pour le train",
@@ -37,17 +34,15 @@
"noPathfinding": "Veuillez relancer la recherche d'itinéraire",
"noRollingStock": "La composition de train n'est pas renseignée",
"noSpeedLimitByTag": "Veuillez choisir un code de composition",
- "noTimeRangeDuration": "La durée de la plage de répétition doit être supérieure à 0",
- "noTimeRangeDurationInput": "Doit être > 0",
"noTimetable": "Veuillez choisir ou créer une grille horaire",
"noTrainCount": "La quantité de trains demandée doit être supérieure à zéro",
- "noTrainCountInput": "Doit être > 0",
"noTrainStep": "Le pas d'incrément du nom du train doit être supérieur à zéro",
- "noTrainStepInput": "Doit être > 0",
"originTimeOutsideWindow": "La date de départ doit être comprise entre le {{low}} et le {{high}}",
"requiredField": "Champ obligatoire.",
"softErrorInfra": "L'application est indisponible, une erreur serveur est survenue, veuillez réessayer ultérieurement.",
"The requested train couldn't reach its destination": "Le train ne peut pas atteindre sa destination",
+ "tooLowInput": "Doit être > 0",
+ "tooLowValue": "La {{value}} doit être supérieure à 0",
"trainScheduleTitle": "Une erreur est survenue",
"unableToDeleteTrain": "Impossible de supprimer le train",
"unableToDuplicateTrain": "Impossible de dupliquer le train",
diff --git a/front/src/modules/trainschedule/components/ManageTrainSchedule/PacedTrainSettings.tsx b/front/src/modules/trainschedule/components/ManageTrainSchedule/PacedTrainSettings.tsx
index 62ede6b7ae1..0233327e6f6 100644
--- a/front/src/modules/trainschedule/components/ManageTrainSchedule/PacedTrainSettings.tsx
+++ b/front/src/modules/trainschedule/components/ManageTrainSchedule/PacedTrainSettings.tsx
@@ -34,7 +34,7 @@ const PacedTrainSettings = () => {
value={timeRangeDuration}
noMargin
isInvalid={timeRangeDuration < 1}
- errorMsg={timeRangeDuration < 1 ? t('errorMessages.noTimeRangeDurationInput') : undefined}
+ errorMsg={timeRangeDuration < 1 ? t('errorMessages.tooLowInput') : undefined}
min={1}
unit="min"
textRight
@@ -57,7 +57,7 @@ const PacedTrainSettings = () => {
value={cadence}
noMargin
isInvalid={cadence < 1}
- errorMsg={cadence < 1 ? t('errorMessages.noCadenceInput') : undefined}
+ errorMsg={cadence < 1 ? t('errorMessages.tooLowInput') : undefined}
min={1}
unit="min"
textRight
diff --git a/front/src/modules/trainschedule/components/ManageTrainSchedule/TrainAddingSettings.tsx b/front/src/modules/trainschedule/components/ManageTrainSchedule/TrainAddingSettings.tsx
index 168971e9c95..2bbce9c8614 100644
--- a/front/src/modules/trainschedule/components/ManageTrainSchedule/TrainAddingSettings.tsx
+++ b/front/src/modules/trainschedule/components/ManageTrainSchedule/TrainAddingSettings.tsx
@@ -58,7 +58,7 @@ export default function TrainAddingSettings() {
value={trainStep}
noMargin
isInvalid={trainStep < 1}
- errorMsg={trainStep < 1 ? t('errorMessages.noTrainStepInput') : undefined}
+ errorMsg={trainStep < 1 ? t('errorMessages.tooLowInput') : undefined}
min={1}
sm
/>
@@ -77,7 +77,7 @@ export default function TrainAddingSettings() {
value={trainCount}
noMargin
isInvalid={trainCount < 1}
- errorMsg={trainCount < 1 ? t('errorMessages.noTrainCountInput') : undefined}
+ errorMsg={trainCount < 1 ? t('errorMessages.tooLowInput') : undefined}
min={1}
sm
/>
@@ -97,7 +97,7 @@ export default function TrainAddingSettings() {
unit="min"
noMargin
isInvalid={trainDelta < 1}
- errorMsg={trainDelta < 1 ? t('errorMessages.noDeltaInput') : undefined}
+ errorMsg={trainDelta < 1 ? t('errorMessages.tooLowInput') : undefined}
min={1}
sm
textRight
diff --git a/front/src/modules/trainschedule/components/ManageTrainSchedule/helpers/checkCurrentConfig.ts b/front/src/modules/trainschedule/components/ManageTrainSchedule/helpers/checkCurrentConfig.ts
index f5fd8e35d14..594158e0f31 100644
--- a/front/src/modules/trainschedule/components/ManageTrainSchedule/helpers/checkCurrentConfig.ts
+++ b/front/src/modules/trainschedule/components/ManageTrainSchedule/helpers/checkCurrentConfig.ts
@@ -1,3 +1,4 @@
+import type { TFunction } from 'i18next';
import { compact } from 'lodash';
import type { Dispatch } from 'redux';
@@ -13,7 +14,7 @@ import formatSchedule from './formatSchedule';
const checkCurrentConfig = (
osrdconf: OperationalStudiesConfState,
- t: (arg0: string) => string,
+ t: TFunction,
dispatch: Dispatch,
// TODO TS2 : remove this when rollingStockName will replace rollingStockId in the store
rollingStockName?: string,
@@ -138,7 +139,9 @@ const checkCurrentConfig = (
dispatch(
setFailure({
name: t('errorMessages.trainScheduleTitle'),
- message: t('errorMessages.noCadence'),
+ message: t('errorMessages.tooLowValue', {
+ value: t('pacedTrains.cadence').toLowerCase(),
+ }),
})
);
}
@@ -147,7 +150,9 @@ const checkCurrentConfig = (
dispatch(
setFailure({
name: t('errorMessages.trainScheduleTitle'),
- message: t('errorMessages.noTimeRangeDuration'),
+ message: t('errorMessages.tooLowValue', {
+ value: t('pacedTrains.timeRangeDuration').toLowerCase(),
+ }),
})
);
}