Skip to content

Commit

Permalink
Formatting + adding translations for error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenga5 committed Dec 3, 2024
1 parent 5d994ab commit db24b73
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 6 additions & 0 deletions src/client/app/translations/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
7 changes: 4 additions & 3 deletions src/client/app/utils/calibration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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){
Expand Down

0 comments on commit db24b73

Please sign in to comment.