diff --git a/internal/webserver/embedded/js/xh-error-check.js b/internal/webserver/embedded/js/xh-error-check.js index 2ac93c9..391e1e9 100644 --- a/internal/webserver/embedded/js/xh-error-check.js +++ b/internal/webserver/embedded/js/xh-error-check.js @@ -1,5 +1,7 @@ document.body.addEventListener('htmx:afterRequest', function (evt) { const errorTarget = document.getElementById("box-error") + const unexpectedServerError = errorTarget.getAttribute("data-unexpected-server-error") + const unexpectedError = errorTarget.getAttribute("data-unexpected-error") if (evt.detail.successful) { // Successful request, clear out alert errorTarget.setAttribute("hidden", "true") @@ -12,12 +14,12 @@ document.body.addEventListener('htmx:afterRequest', function (evt) { } console.warn("Server error", evt.detail) - errorTarget.innerText = `Unexpected server error: ${xhr.status} - ${xhr.statusText}`; - errorTarget.removeAttribute("hidden"); + errorTarget.innerText = unexpectedServerError + `${xhr.status} - ${xhr.statusText}` + errorTarget.removeAttribute("hidden") } else { // Unspecified failure, usually caused by network error console.error("Unexpected htmx error", evt.detail) - errorTarget.innerText = "Unexpected error, check your connection and try to refresh the page."; - errorTarget.removeAttribute("hidden"); + errorTarget.innerText = unexpectedError + errorTarget.removeAttribute("hidden") } -}); \ No newline at end of file +}); diff --git a/internal/webserver/embedded/translations/es.yml b/internal/webserver/embedded/translations/es.yml index 3c355f1..5a31073 100644 --- a/internal/webserver/embedded/translations/es.yml +++ b/internal/webserver/embedded/translations/es.yml @@ -133,3 +133,6 @@ "Go left": "Ir a la izquierda" "Go right": "Ir a la derecha" "Session expired, please log in again.": "Sesión expirada, por favor identifícate de nuevo." +"Unexpected error, check your connection and try to refresh the page.": "Error inesperado, comprueba tu conexión y recarga la página." +"Unexpected server error": "Error inesperado en el servidor" + diff --git a/internal/webserver/embedded/translations/fr.yml b/internal/webserver/embedded/translations/fr.yml index 7a71638..da1d205 100644 --- a/internal/webserver/embedded/translations/fr.yml +++ b/internal/webserver/embedded/translations/fr.yml @@ -133,3 +133,5 @@ "Go left": "Aller à gauche" "Go right": "Aller à droite" "Session expired, please log in again.": "Session expirée, veuillez vous reconnecter." +"Unexpected error, check your connection and try to refresh the page.": "Erreur inattendue, vérifiez votre connexion et essayez d'actualiser la page." +"Unexpected server error": "Erreur de serveur inattendue" diff --git a/internal/webserver/embedded/views/partials/main.html b/internal/webserver/embedded/views/partials/main.html index 30d7b49..32dcb17 100644 --- a/internal/webserver/embedded/views/partials/main.html +++ b/internal/webserver/embedded/views/partials/main.html @@ -12,7 +12,7 @@ {{end}}