Translate an error message
This commit is contained in:
parent
2b7e88ae95
commit
3bc17cea79
6 changed files with 18 additions and 7 deletions
|
|
@ -10,11 +10,11 @@ use serde::Deserialize;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
app::{AppState, Context, Result},
|
app::{AppState, Context, Result},
|
||||||
consts,
|
|
||||||
data::db,
|
data::db,
|
||||||
html_templates::*,
|
html_templates::*,
|
||||||
log::Log,
|
log::Log,
|
||||||
ron_utils,
|
ron_utils,
|
||||||
|
translation::Sentence,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub mod fragments;
|
pub mod fragments;
|
||||||
|
|
@ -98,7 +98,10 @@ pub async fn dev_panel(
|
||||||
} else {
|
} else {
|
||||||
Ok((
|
Ok((
|
||||||
StatusCode::UNAUTHORIZED,
|
StatusCode::UNAUTHORIZED,
|
||||||
Html(MessageTemplate::new(consts::NOT_AUTHORIZED_MESSAGE, context).render()?),
|
Html(
|
||||||
|
MessageTemplate::new(context.tr.t(Sentence::ActionNotAuthorized), context)
|
||||||
|
.render()?,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
.into_response())
|
.into_response())
|
||||||
}
|
}
|
||||||
|
|
@ -145,7 +148,10 @@ pub async fn logs(
|
||||||
} else {
|
} else {
|
||||||
Ok((
|
Ok((
|
||||||
StatusCode::UNAUTHORIZED,
|
StatusCode::UNAUTHORIZED,
|
||||||
Html(MessageTemplate::new(consts::NOT_AUTHORIZED_MESSAGE, context).render()?),
|
Html(
|
||||||
|
MessageTemplate::new(context.tr.t(Sentence::ActionNotAuthorized), context)
|
||||||
|
.render()?,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
.into_response())
|
.into_response())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,10 @@ use axum_extra::extract::Query;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
app::Context,
|
app::Context,
|
||||||
consts,
|
|
||||||
data::{self, db},
|
data::{self, db},
|
||||||
ron_extractor::ExtractRon,
|
ron_extractor::ExtractRon,
|
||||||
ron_utils::{ron_error, ron_response_ok},
|
ron_utils::{ron_error, ron_response_ok},
|
||||||
|
translation::Sentence,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::rights::*;
|
use super::rights::*;
|
||||||
|
|
@ -31,7 +31,7 @@ pub async fn get_scheduled_recipes(
|
||||||
} else {
|
} else {
|
||||||
Err(ErrorResponse::from(ron_error(
|
Err(ErrorResponse::from(ron_error(
|
||||||
StatusCode::UNAUTHORIZED,
|
StatusCode::UNAUTHORIZED,
|
||||||
consts::NOT_AUTHORIZED_MESSAGE,
|
context.tr.t(Sentence::ActionNotAuthorized),
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ use axum::{
|
||||||
response::{IntoResponse, Result},
|
response::{IntoResponse, Result},
|
||||||
};
|
};
|
||||||
use axum_extra::extract::cookie::{Cookie, CookieJar, SameSite};
|
use axum_extra::extract::cookie::{Cookie, CookieJar, SameSite};
|
||||||
// use tracing::{event, Level};
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
app::Context, consts, data::db, data::model, ron_extractor::ExtractRon, ron_utils::ron_error,
|
app::Context, consts, data::db, data::model, ron_extractor::ExtractRon, ron_utils::ron_error,
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,8 @@ pub enum Sentence {
|
||||||
Save,
|
Save,
|
||||||
NotLoggedIn,
|
NotLoggedIn,
|
||||||
|
|
||||||
|
ActionNotAuthorized,
|
||||||
|
|
||||||
DatabaseError,
|
DatabaseError,
|
||||||
TemplateError,
|
TemplateError,
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
{% if user.is_admin %}
|
{% if user.is_admin %}
|
||||||
<a class="button" href="/logs">Logs</a><a class="button" href="/dev_panel">Dev panel</a>
|
<a class="button" href="/logs">Logs</a><a class="button" href="/dev_panel">Dev panel</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<a href="/{{ context.tr.current_lang_code() }}/user/edit">
|
<a class="user-edit-link" href="/{{ context.tr.current_lang_code() }}/user/edit">
|
||||||
{% if user.name == "" %}
|
{% if user.name == "" %}
|
||||||
{{ user.email }}
|
{{ user.email }}
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,8 @@
|
||||||
(Save, "Save"),
|
(Save, "Save"),
|
||||||
(NotLoggedIn, "No logged in"),
|
(NotLoggedIn, "No logged in"),
|
||||||
|
|
||||||
|
(ActionNotAuthorized, "Action not authorized"),
|
||||||
|
|
||||||
(DatabaseError, "Database error"),
|
(DatabaseError, "Database error"),
|
||||||
(TemplateError, "Template error"),
|
(TemplateError, "Template error"),
|
||||||
|
|
||||||
|
|
@ -165,6 +167,8 @@
|
||||||
(Save, "Sauvegarder"),
|
(Save, "Sauvegarder"),
|
||||||
(NotLoggedIn, "Pas connecté"),
|
(NotLoggedIn, "Pas connecté"),
|
||||||
|
|
||||||
|
(ActionNotAuthorized, "Action non autorisée"),
|
||||||
|
|
||||||
(DatabaseError, "Erreur de la base de données (Database error)"),
|
(DatabaseError, "Erreur de la base de données (Database error)"),
|
||||||
(TemplateError, "Erreur du moteur de modèles (Template error)"),
|
(TemplateError, "Erreur du moteur de modèles (Template error)"),
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue