Commit 2ca06f9d authored by Stephane Glondu's avatar Stephane Glondu

Internationalize error messages

parent 97e338b3
......@@ -66,19 +66,20 @@ exception Error of error
let fail e = Lwt.fail (Error e)
let explain_error = function
| Serialization e ->
Printf.sprintf "your ballot has a syntax error (%s)" (Printexc.to_string e)
| ProofCheck -> "some proofs failed verification"
| ElectionClosed -> "the election is closed"
| MissingCredential -> "a credential is missing"
| InvalidCredential -> "your credential is invalid"
| RevoteNotAllowed -> "you are not allowed to revote"
| ReusedCredential -> "your credential has already been used"
| WrongCredential -> "you are not allowed to vote with this credential"
| UsedCredential -> "the credential has already been used"
| CredentialNotFound -> "the credential has not been found"
| UnauthorizedVoter -> "you are not allowed to vote"
let explain_error l e =
let module L = (val l : Web_i18n_sig.LocalizedStrings) in
match e with
| Serialization e -> Printf.sprintf L.error_Serialization (Printexc.to_string e)
| ProofCheck -> L.error_ProofCheck
| ElectionClosed -> L.error_ElectionClosed
| MissingCredential -> L.error_MissingCredential
| InvalidCredential -> L.error_InvalidCredential
| RevoteNotAllowed -> L.error_RevoteNotAllowed
| ReusedCredential -> L.error_ReusedCredential
| WrongCredential -> L.error_WrongCredential
| UsedCredential -> L.error_UsedCredential
| CredentialNotFound -> L.error_CredentialNotFound
| UnauthorizedVoter -> L.error_UnauthorizedVoter
let security_logfile = ref None
......
......@@ -48,7 +48,7 @@ exception Error of error
val fail : error -> 'a Lwt.t
val explain_error : error -> string
val explain_error : (module Web_i18n_sig.LocalizedStrings) -> error -> string
val open_security_log : string -> unit Lwt.t
(** Set the path to the security logger. *)
......
......@@ -121,4 +121,15 @@ module type LocalizedStrings = sig
val mail_confirmation_subject : (string -> 'f, 'b, 'c, 'e, 'e, 'f) format6
val mail_confirmation : (string -> string -> string -> string -> string -> string -> 'f, 'b, 'c, 'e, 'e, 'f) format6
val please_contact : string
val error_Serialization : (string -> 'f, 'b, 'c, 'e, 'e, 'f) format6
val error_ProofCheck : string
val error_ElectionClosed : string
val error_MissingCredential : string
val error_InvalidCredential : string
val error_RevoteNotAllowed : string
val error_ReusedCredential : string
val error_WrongCredential : string
val error_UsedCredential : string
val error_CredentialNotFound : string
val error_UnauthorizedVoter : string
end
......@@ -188,3 +188,15 @@ Das Ergebnis wird auf der Website der Abstimmung veröffentlicht:
-- \nBelenios"
let please_contact = "To get more information, please contact:"
let error_Serialization : ('a, 'b, 'c, 'd, 'e, 'f) format6 = "your ballot has a syntax error (%s)"
let error_ProofCheck = "some proofs failed verification"
let error_ElectionClosed = "the election is closed"
let error_MissingCredential = "a credential is missing"
let error_InvalidCredential = "your credential is invalid"
let error_RevoteNotAllowed = "you are not allowed to revote"
let error_ReusedCredential = "your credential has already been used"
let error_WrongCredential = "you are not allowed to vote with this credential"
let error_UsedCredential = "the credential has already been used"
let error_CredentialNotFound = "the credential has not been found"
let error_UnauthorizedVoter = "you are not allowed to vote"
......@@ -186,3 +186,15 @@ Results will be published on the election page
-- \nBelenios"
let please_contact = "To get more information, please contact:"
let error_Serialization : ('a, 'b, 'c, 'd, 'e, 'f) format6 = "your ballot has a syntax error (%s)"
let error_ProofCheck = "some proofs failed verification"
let error_ElectionClosed = "the election is closed"
let error_MissingCredential = "a credential is missing"
let error_InvalidCredential = "your credential is invalid"
let error_RevoteNotAllowed = "you are not allowed to revote"
let error_ReusedCredential = "your credential has already been used"
let error_WrongCredential = "you are not allowed to vote with this credential"
let error_UsedCredential = "the credential has already been used"
let error_CredentialNotFound = "the credential has not been found"
let error_UnauthorizedVoter = "you are not allowed to vote"
......@@ -189,3 +189,15 @@ Les résultats seront publiés sur la page de l'élection
-- \nBelenios"
let please_contact = "Pour obtenir plus d'informations, veuillez contacter :"
let error_Serialization : ('a, 'b, 'c, 'd, 'e, 'f) format6 = "votre bulletin a une erreur de syntaxe (%s)"
let error_ProofCheck = "certaines preuves sont invalides"
let error_ElectionClosed = "l'élection est fermée"
let error_MissingCredential = "un code de vote manque"
let error_InvalidCredential = "votre code de vote est invalide"
let error_RevoteNotAllowed = "vous n'êtes pas autorisé(e) à revoter"
let error_ReusedCredential = "votre code de vote a déjà été utilisé"
let error_WrongCredential = "vous n'êtes pas autorisé(e) à voter avec ce code de vote"
let error_UsedCredential = "le code de vote a déjà été utilisé"
let error_CredentialNotFound = "le code de vote n'a pas été trouvé"
let error_UnauthorizedVoter = "vous n'êtes pas autorisé(e) a voter"
......@@ -191,3 +191,15 @@ I risultati saranno pubblicati sulla pagina dell'elezione
-- \nBelenios"
let please_contact = "To get more information, please contact:"
let error_Serialization : ('a, 'b, 'c, 'd, 'e, 'f) format6 = "your ballot has a syntax error (%s)"
let error_ProofCheck = "some proofs failed verification"
let error_ElectionClosed = "the election is closed"
let error_MissingCredential = "a credential is missing"
let error_InvalidCredential = "your credential is invalid"
let error_RevoteNotAllowed = "you are not allowed to revote"
let error_ReusedCredential = "your credential has already been used"
let error_WrongCredential = "you are not allowed to vote with this credential"
let error_UsedCredential = "the credential has already been used"
let error_CredentialNotFound = "the credential has not been found"
let error_UnauthorizedVoter = "you are not allowed to vote"
......@@ -188,3 +188,15 @@ Rezultatele vor fi publicate pe pagina de alegere
-- \nBelenios"
let please_contact = "To get more information, please contact:"
let error_Serialization : ('a, 'b, 'c, 'd, 'e, 'f) format6 = "your ballot has a syntax error (%s)"
let error_ProofCheck = "some proofs failed verification"
let error_ElectionClosed = "the election is closed"
let error_MissingCredential = "a credential is missing"
let error_InvalidCredential = "your credential is invalid"
let error_RevoteNotAllowed = "you are not allowed to revote"
let error_ReusedCredential = "your credential has already been used"
let error_WrongCredential = "you are not allowed to vote with this credential"
let error_UsedCredential = "the credential has already been used"
let error_CredentialNotFound = "the credential has not been found"
let error_UnauthorizedVoter = "you are not allowed to vote"
......@@ -1309,7 +1309,9 @@ let () =
B.update_cred ~old ~new_ >>
String.send ("OK", "text/plain")
with Error e ->
String.send ("Error: " ^ explain_error e, "text/plain")
let%lwt lang = Eliom_reference.get Web_state.language in
let l = Web_i18n.get_lang lang in
String.send ("Error: " ^ explain_error l e, "text/plain")
) else forbidden ()
)
)
......
......@@ -2104,7 +2104,8 @@ let cast_confirmation election hash () =
let cast_confirmed election ~result () =
let%lwt language = Eliom_reference.get Web_state.language in
let module L = (val Web_i18n.get_lang language) in
let l = Web_i18n.get_lang language in
let module L = (val l) in
let params = election.e_params in
let uuid = params.e_uuid in
let name = params.e_name in
......@@ -2137,7 +2138,7 @@ let cast_confirmed election ~result () =
], L.thank_you_for_voting
| `Error e ->
[pcdata L.is_rejected_because;
pcdata (Web_common.explain_error e);
pcdata (Web_common.explain_error l e);
pcdata ".";
], L.fail
in
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment