Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions front/public/locales/de/operational-studies.json
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,11 @@
"simulationSheet": "Simulationsblatt",
"speedDistanceDiagram": "GSD",
"speedDistanceSettings": {
"accelerating": "Beschleunigung",
"coasting": "Ausrollen",
"context": "Kontext",
"decelerating": "Verzögerung",
"electric": "Elektrisch",
"electricalProfiles": "Bahnstromprofile",
"energySource": "Energiequelle",
"etcs": {
Expand All @@ -554,6 +558,7 @@
"title": "ETCS",
"transition": "Überg."
},
"incompatible": "Unvereinbar",
"powerRestrictions": "Leistungsbeschränkungen",
"reticleInfos": "Fadenkreuz-Infos",
"slopes": "Längsneigungen",
Expand Down
5 changes: 5 additions & 0 deletions front/public/locales/en/operational-studies.json
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,11 @@
"simulationSheet": "Train path sheet",
"speedDistanceDiagram": "SDD",
"speedDistanceSettings": {
"accelerating": "Accelerating",
"coasting": "Coasting",
"context": "Context",
"decelerating": "Decelerating",
"electric": "Electric",
"electricalProfiles": "Electrical profiles",
"energySource": "Energy source",
"etcs": {
Expand All @@ -646,6 +650,7 @@
"title": "ETCS",
"transition": "Trans."
},
"incompatible": "Incompatible",
"invalidSimulation": "The selected train can't be simulated",
"noData": "Data is displayed when a train is selected",
"powerRestrictions": "Power restrictions",
Expand Down
5 changes: 5 additions & 0 deletions front/public/locales/fr/operational-studies.json
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,11 @@
"simulationSheet": "Fiche de tracé",
"speedDistanceDiagram": "GEV",
"speedDistanceSettings": {
"accelerating": "En accélération",
"coasting": "En roue libre",
"context": "Contexte",
"decelerating": "En décélération",
"electric": "Électrique",
"electricalProfiles": "Profils électrique",
"energySource": "Source d'énergie",
"etcs": {
Expand All @@ -646,6 +650,7 @@
"title": "ETCS",
"transition": "Trans."
},
"incompatible": "Incompatible",
"invalidSimulation": "Le train sélectionné ne peut pas être simulé",
"noData": "La donnée est affichée lorsqu'un train est sélectionné",
"powerRestrictions": "Restrictions de puissance",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ const SpeedDistanceDiagramWrapper = ({
etcs: t('speedDistanceSettings.etcs.title'),
electricalProfiles: t('speedDistanceSettings.electricalProfiles'),
powerRestrictions: t('speedDistanceSettings.powerRestrictions'),
reticleValues: {
incompatible: t('speedDistanceSettings.incompatible'),
electric: t('speedDistanceSettings.electric'),
accelerating: t('speedDistanceSettings.accelerating'),
decelerating: t('speedDistanceSettings.decelerating'),
coasting: t('speedDistanceSettings.coasting'),
},
},
layersDisplay: {
context: t('speedDistanceSettings.context'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ export const defaultTranslations = {
etcs: 'ETCS',
electricalProfiles: 'Electrical Profiles',
powerRestrictions: 'Power Restrictions',
reticleValues: {
incompatible: 'Incompatible',
electric: 'Electric',
accelerating: 'Accelerating',
decelerating: 'Decelerating',
coasting: 'Coasting',
},
},
layersDisplay: {
context: 'Context',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ export type SpeedSpaceChartProps = {
etcs: string;
electricalProfiles: string;
powerRestrictions: string;
reticleValues: {
incompatible: string;
electric: string;
accelerating: string;
decelerating: string;
coasting: string;
};
};
layersDisplay: {
context: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,18 @@ const DetailsBox = ({
const speedDifference = Number(speedText) - Number(ecoSpeedText);
const speedDifferenceText = speedDifference !== 0 ? `-${speedDifference.toFixed(1)}` : null;

const reticleValues = translations?.detailsBoxDisplay.reticleValues;
const translatedModeText =
modeText === '--'
? modeText
: (reticleValues?.[modeText as keyof typeof reticleValues] ?? modeText);
const translatedEffortText =
reticleValues?.[effortText as keyof typeof reticleValues] ?? effortText;
const translatedElectricalProfileText =
electricalProfileText === 'incompatible'
? (reticleValues?.incompatible ?? electricalProfileText)
: electricalProfileText;
Comment on lines +72 to +82

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look very clean since we compute first the text and replace it some times with the translations.

Maybe it would be better if we could pass translations directly in drawCursor to use them over there to compute the text. Do you think it's acceptable for osrd-ui @emersion ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK as in movieng out the null/Undefined checking to the parent ,

or how about

const reticleValues = translations?.detailsBoxDisplay.reticleValues as Record<string, string> | undefined;

const translatedModeText = reticleValues?.[modeText] ?? modeText;
const translatedEffortText = reticleValues?.[effortText] ?? effortText;
const translatedElectricalProfileText = reticleValues?.[electricalProfileText] ?? electricalProfileText; 

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get the point about compute-then-replace, but I'm not sure passing translations down to drawCursor is the right move : it's a canvas drawing function running on every mousemove, and we'd have to thread translations through DrawFunctionParams, which is shared with all the other draw* functions.

To me the actual issue is that modeText and effortText are typed as plain string in TrainDetails. That's what forces the as keyof typeof reticleValues cast. If we type them as unions instead :

export type ReticleMode = 'electric' | '--';
export type ReticleEffort = 'coasting' | 'accelerating' | 'decelerating';

the lookup gets simple, no cast and no '--' special case :

const reticleValues = translations?.detailsBoxDisplay.reticleValues;
const translatedEffortText = reticleValues?.[effortText] ?? effortText;
...

What do you think ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we have a look @kmer2016 @SharglutDev


const activeEtcsBrakingTypes = getActiveEtcsBrakingTypes(store.etcsLayersDisplay);
const activeEtcsBrakingCurveTypes = getActiveEtcsBrakingCurveTypes(store.etcsLayersDisplay);
const etcsEndOfCurves = etcsSpeedValues
Expand Down Expand Up @@ -102,12 +114,14 @@ const DetailsBox = ({
{speedDifferenceText && <span id="speed-difference-text">{speedDifferenceText}</span>}
</div>
{(energySource || tractionStatus || modeText || effortText) && <hr />}
{energySource && <span id="mode-text">{modeText || '--'}</span>}
{tractionStatus && <span id="effort-text">{effortText || '--'}</span>}
{energySource && <span id="mode-text">{translatedModeText || '--'}</span>}
{tractionStatus && <span id="effort-text">{translatedEffortText || '--'}</span>}
{electricalModeText && (
<div id="electrical-mode-text">
<span>{electricalModeText || '--'}</span>
{electricalProfiles && <span className="ml-2">{electricalProfileText || '--'}</span>}
{electricalProfiles && (
<span className="ml-2">{translatedElectricalProfileText || '--'}</span>
)}
</div>
)}
{powerRestrictions && (
Expand Down