Skip to content

Commit e648bc2

Browse files
committed
feat: use translations for error messages
1 parent 7248aa0 commit e648bc2

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

web/frontend/src/language/de.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,9 @@
294294
"footerBuildTime": "in:",
295295
"voteNotVoter": "Wählen nicht erlaubt.",
296296
"voteNotVoterDescription": "Sie sind nicht wahlberechtigt in dieser Wahl. Falls Sie denken, dass ein Fehler vorliegt, wenden Sie sich bitte an die verantwortliche Stelle.",
297-
"addVotersLoading": "WählerInnen werden hinzugefügt..."
297+
"addVotersLoading": "WählerInnen werden hinzugefügt...",
298+
"sciperNaN": "'{{sciperStr}}' ist keine Zahl; ",
299+
"sciperOutOfRange": "{{sciper}} ist nicht in dem erlaubten Bereich (100000-999999); ",
300+
"invalidScipersFound": "Ungültige SCIPERs wurden gefunden. Es wurde keine Anfrage gesendet. Bitte korrigieren Sie folgende Fehler: {{sciperErrs}}"
298301
}
299302
}

web/frontend/src/language/en.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,9 @@
295295
"footerBuildTime": "in:",
296296
"voteNotVoter": "Voting not allowed.",
297297
"voteNotVoterDescription": "You are not allowed to vote in this form. If you believe this is an error, please contact the responsible of the service.",
298-
"addVotersLoading": "Adding voters..."
298+
"addVotersLoading": "Adding voters...",
299+
"sciperNaN": "'{{sciperStr}}' is not a number; ",
300+
"sciperOutOfRange": "{{sciper}} is out of range (100000-999999); ",
301+
"invalidScipersFound": "Invalid SCIPER numbers found. No request has been send. Please fix the following errors: {{sciperErrs}}"
299302
}
300303
}

web/frontend/src/language/fr.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,9 @@
294294
"footerBuildTime": "en:",
295295
"voteNotVoter": "Interdit de voter.",
296296
"voteNotVoterDescription": "Vous n'avez pas le droit de voter dans cette élection. Si vous pensez qu'il s'agit d'une erreur, veuillez contacter le/la reponsable de service.",
297-
"addVotersLoading": "Ajout d'électeur·rice·s..."
297+
"addVotersLoading": "Ajout d'électeur·rice·s...",
298+
"sciperNaN": "'{{sciperStr}}' n'est pas une chiffre; ",
299+
"sciperOutOfRange": "{{sciper}} n'est pas dans les valeurs acceptées (100000-999999); ",
300+
"invalidScipersFound": "Des SCIPERs invalides ont été trouvés. Aucune requête n'a été envoyée. Veuillez corriger les erreurs suivants: {{sciperErrs}}"
298301
}
299302
}

web/frontend/src/pages/form/components/utils/useChangeAction.tsx

+3-6
Original file line numberDiff line numberDiff line change
@@ -322,17 +322,14 @@ const useChangeAction = (
322322
for (const sciperStr of providedScipers) {
323323
const sciper = parseInt(sciperStr, 10);
324324
if (isNaN(sciper)) {
325-
sciperErrs += `'${sciperStr}' is not a number; `;
325+
sciperErrs += t('sciperNaN', { sciperStr: sciperStr });
326326
}
327327
if (sciper < 100000 || sciper > 999999) {
328-
sciperErrs += `${sciper} is out of range (100000-999999); `;
328+
sciperErrs += t('sciperOutOfRange', { sciper: sciper });
329329
}
330330
}
331331
if (sciperErrs.length > 0) {
332-
console.error('Invalid SCIPER numbers found. No request will be send.');
333-
setTextModalError(
334-
`Invalid SCIPER numbers found. No request has been send. Please fix the following errors: ${sciperErrs}`
335-
);
332+
setTextModalError(t('invalidScipersFound', { sciperErrs: sciperErrs }));
336333
setShowModalError(true);
337334
return;
338335
}

0 commit comments

Comments
 (0)