From db24b73783e4e5c10745c22d2d7e27d919176a2a Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 3 Dec 2024 14:25:41 -0500 Subject: [PATCH] Formatting + adding translations for error messages --- .../app/components/groups/CreateGroupModalComponent.tsx | 4 ---- src/client/app/translations/data.ts | 6 ++++++ src/client/app/utils/calibration.ts | 7 ++++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/client/app/components/groups/CreateGroupModalComponent.tsx b/src/client/app/components/groups/CreateGroupModalComponent.tsx index 3ab3a5cbc..b2a74a9a1 100644 --- a/src/client/app/components/groups/CreateGroupModalComponent.tsx +++ b/src/client/app/components/groups/CreateGroupModalComponent.tsx @@ -208,10 +208,6 @@ export default function CreateGroupModalComponent() { }; // gpsInput must be of type string but TS does not think so so cast. } else if ((gpsInput as string).length !== 0) { - // GPS not okay. Only true if some input. - // TODO isValidGPSInput currently pops up an alert so not doing it here, may change - // so leaving code commented out. - // showErrorNotification(translate('input.gps.range') + state.gps + '.'); showErrorNotification(message); inputOk = false; } diff --git a/src/client/app/translations/data.ts b/src/client/app/translations/data.ts index 91795e891..b8fde5bfc 100644 --- a/src/client/app/translations/data.ts +++ b/src/client/app/translations/data.ts @@ -176,6 +176,8 @@ const LocaleTranslationData = { "failed.to.submit.changes": "Failed to submit changes", "false": "False", "gps": "GPS: latitude, longitude", + "gps.missing.comma": "GPS Input is missing a comma", + "gps.many.comma": "GPS Input has too many commas", "graph": "Graph", "graph.settings": "Graph Settings", "graph.type": "Graph Type", @@ -698,6 +700,8 @@ const LocaleTranslationData = { "failed.to.submit.changes": "Échec de l'envoi des modifications", "false": "Faux", "gps": "GPS: latitude, longitude\u{26A1}", + "gps.missing.comma": "GPS Input is missing a comma\u{26A1}", + "gps.many.comma": "GPS Input has too many commas\u{26A1}", "graph": "Graphique", "graph.settings": "Graph Settings\u{26A1}", "graph.type": "Type du Diagramme", @@ -1221,6 +1225,8 @@ const LocaleTranslationData = { "failed.to.submit.changes": "No se pudo entregar los cambios", "false": "Falso", "gps": "GPS: latitud, longitud", + "gps.missing.comma": "GPS Input is missing a comma\u{26A1}", + "gps.many.comma": "GPS Input has too many commas\u{26A1}", "graph": "Gráfico", "graph.settings": "Graph Settings\u{26A1}", "graph.type": "Tipo de gráfico", diff --git a/src/client/app/utils/calibration.ts b/src/client/app/utils/calibration.ts index 84368103b..d0553f587 100644 --- a/src/client/app/utils/calibration.ts +++ b/src/client/app/utils/calibration.ts @@ -67,7 +67,8 @@ export interface Dimensions { } /** - * Returns true if item (meter or group) and map and reasonably defined and false otherwise. + * Returns true if item (meter or group) and map and reasonably defined + * Returns false and a message about the reason the input is invalid otherwise * @param itemID ID to be used for logging errors * @param type DataType to distinguish between meter and group * @param map map info to check @@ -111,10 +112,10 @@ export function isValidGPSInput(input: string){ let validGps = true; if (input.indexOf(',') === -1) { // if there is no comma // TODO It would be nice to tell user that comma is missing but need to check all uses to be sure don't get ''. - message = 'GPS Input is missing a comma'; //Translate later + message = translate('gps.missing.comma'); validGps = false; } else if (input.indexOf(',') !== input.lastIndexOf(',')) { // if there are multiple commas - message = 'GPS Input has too many commas'; //Translate later + message = translate('gps.many.comma'); validGps = false; } if(validGps){