Translation (WIP)
This commit is contained in:
parent
9b0fcec5e2
commit
e9873c1943
29 changed files with 586 additions and 285 deletions
|
|
@ -1,6 +1,9 @@
|
|||
use askama::Template;
|
||||
use rinja_axum::Template;
|
||||
|
||||
use crate::data::model;
|
||||
use crate::{
|
||||
data::model,
|
||||
translation::{Sentence, Tr},
|
||||
};
|
||||
|
||||
pub struct Recipes {
|
||||
pub published: Vec<(i64, String)>,
|
||||
|
|
@ -18,6 +21,8 @@ impl Recipes {
|
|||
#[template(path = "home.html")]
|
||||
pub struct HomeTemplate {
|
||||
pub user: Option<model::User>,
|
||||
pub tr: Tr,
|
||||
|
||||
pub recipes: Recipes,
|
||||
}
|
||||
|
||||
|
|
@ -25,23 +30,26 @@ pub struct HomeTemplate {
|
|||
#[template(path = "message.html")]
|
||||
pub struct MessageTemplate {
|
||||
pub user: Option<model::User>,
|
||||
pub tr: Tr,
|
||||
|
||||
pub message: String,
|
||||
pub as_code: bool, // Display the message in <pre> markup.
|
||||
}
|
||||
|
||||
impl MessageTemplate {
|
||||
pub fn new(message: &str) -> MessageTemplate {
|
||||
pub fn new(message: &str, tr: Tr) -> MessageTemplate {
|
||||
MessageTemplate {
|
||||
user: None,
|
||||
tr,
|
||||
message: message.to_string(),
|
||||
as_code: false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_with_user(message: &str, user: Option<model::User>) -> MessageTemplate {
|
||||
pub fn new_with_user(message: &str, tr: Tr, user: Option<model::User>) -> MessageTemplate {
|
||||
MessageTemplate {
|
||||
user,
|
||||
tr,
|
||||
message: message.to_string(),
|
||||
as_code: false,
|
||||
}
|
||||
|
|
@ -52,6 +60,7 @@ impl MessageTemplate {
|
|||
#[template(path = "sign_up_form.html")]
|
||||
pub struct SignUpFormTemplate {
|
||||
pub user: Option<model::User>,
|
||||
pub tr: Tr,
|
||||
|
||||
pub email: String,
|
||||
pub message: String,
|
||||
|
|
@ -63,6 +72,7 @@ pub struct SignUpFormTemplate {
|
|||
#[template(path = "sign_in_form.html")]
|
||||
pub struct SignInFormTemplate {
|
||||
pub user: Option<model::User>,
|
||||
pub tr: Tr,
|
||||
|
||||
pub email: String,
|
||||
pub message: String,
|
||||
|
|
@ -72,6 +82,7 @@ pub struct SignInFormTemplate {
|
|||
#[template(path = "ask_reset_password.html")]
|
||||
pub struct AskResetPasswordTemplate {
|
||||
pub user: Option<model::User>,
|
||||
pub tr: Tr,
|
||||
|
||||
pub email: String,
|
||||
pub message: String,
|
||||
|
|
@ -82,6 +93,7 @@ pub struct AskResetPasswordTemplate {
|
|||
#[template(path = "reset_password.html")]
|
||||
pub struct ResetPasswordTemplate {
|
||||
pub user: Option<model::User>,
|
||||
pub tr: Tr,
|
||||
|
||||
pub reset_token: String,
|
||||
pub message: String,
|
||||
|
|
@ -92,6 +104,7 @@ pub struct ResetPasswordTemplate {
|
|||
#[template(path = "profile.html")]
|
||||
pub struct ProfileTemplate {
|
||||
pub user: Option<model::User>,
|
||||
pub tr: Tr,
|
||||
|
||||
pub username: String,
|
||||
pub email: String,
|
||||
|
|
@ -104,6 +117,8 @@ pub struct ProfileTemplate {
|
|||
#[template(path = "recipe_view.html")]
|
||||
pub struct RecipeViewTemplate {
|
||||
pub user: Option<model::User>,
|
||||
pub tr: Tr,
|
||||
|
||||
pub recipes: Recipes,
|
||||
|
||||
pub recipe: model::Recipe,
|
||||
|
|
@ -113,6 +128,8 @@ pub struct RecipeViewTemplate {
|
|||
#[template(path = "recipe_edit.html")]
|
||||
pub struct RecipeEditTemplate {
|
||||
pub user: Option<model::User>,
|
||||
pub tr: Tr,
|
||||
|
||||
pub recipes: Recipes,
|
||||
|
||||
pub recipe: model::Recipe,
|
||||
|
|
@ -123,5 +140,7 @@ pub struct RecipeEditTemplate {
|
|||
#[template(path = "recipes_list_fragment.html")]
|
||||
pub struct RecipesListFragmentTemplate {
|
||||
pub user: Option<model::User>,
|
||||
pub tr: Tr,
|
||||
|
||||
pub recipes: Recipes,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue