initial translatability
This commit is contained in:
+12
@@ -25,6 +25,7 @@ use std::{fmt::Display, path::PathBuf, str::FromStr};
|
||||
use actix_identity::{CookieIdentityPolicy, IdentityService};
|
||||
use actix_web::{web, App, HttpResponse, HttpServer};
|
||||
|
||||
use fluent_templates::{static_loader, FluentLoader};
|
||||
use qrcode::types::QrError;
|
||||
use sqlx::{Pool, Sqlite};
|
||||
use tera::Tera;
|
||||
@@ -188,9 +189,20 @@ impl ServerConfig {
|
||||
}
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/generated.rs"));
|
||||
|
||||
static_loader! {
|
||||
static LOCALES = {
|
||||
locales: "./locales",
|
||||
fallback_language: "en",
|
||||
};
|
||||
}
|
||||
|
||||
fn build_tera() -> Tera {
|
||||
let mut tera = Tera::default();
|
||||
|
||||
// Add translation support
|
||||
tera.register_function("fluent", FluentLoader::new(&*LOCALES));
|
||||
|
||||
tera.add_raw_templates(vec![
|
||||
("admin.html", include_str!("../templates/admin.html")),
|
||||
("base.html", include_str!("../templates/base.html")),
|
||||
|
||||
@@ -11,6 +11,7 @@ pub struct User {
|
||||
pub email: String,
|
||||
pub password: String,
|
||||
pub role: i64,
|
||||
pub language: String,
|
||||
}
|
||||
|
||||
impl User {
|
||||
|
||||
@@ -81,6 +81,7 @@ pub(crate) async fn list_all_allowed(
|
||||
users.username as usern,
|
||||
users.email as uemail,
|
||||
users.role as urole,
|
||||
users.language as ulang,
|
||||
count(clicks.id) as counter
|
||||
from
|
||||
links
|
||||
@@ -107,6 +108,7 @@ pub(crate) async fn list_all_allowed(
|
||||
email: v.get("uemail"),
|
||||
password: "invalid".to_owned(),
|
||||
role: v.get("urole"),
|
||||
language: v.get("ulang"),
|
||||
},
|
||||
clicks: Count {
|
||||
number: v.get("counter"), /* count is never None */
|
||||
@@ -244,6 +246,7 @@ pub(crate) async fn update_user(
|
||||
email: data.email.clone(),
|
||||
password,
|
||||
role: unmodified_user.role,
|
||||
language: unmodified_user.language,
|
||||
};
|
||||
new_user.update_user(server_config).await?;
|
||||
let changed_user = User::get_user(uid, server_config).await?;
|
||||
|
||||
Reference in New Issue
Block a user