rust
Elnu 1 year ago
parent 3abc45cd4f
commit 857832e052

@ -8,4 +8,4 @@ pub mod user {
pub const USER_DISCRIMINATOR_COOKIE: &str = "user_discriminator";
pub const USER_AVATAR_COOKIE: &str = "user_avatar";
}
pub const LANG_COOKIE: &str = "lang";
pub const LANG_COOKIE: &str = "lang";

@ -56,14 +56,11 @@ pub fn load_catalogs() -> Result<(Catalogs, Vec<LangCode>), LoadCatalogsError> {
}
let langs = catalogs
.iter()
.map(|(code, catalog)|
LangCode {
code: code.clone(),
name: catalog
.gettext("lang")
.to_owned(),
}
).collect();
.map(|(code, catalog)| LangCode {
code: code.clone(),
name: catalog.gettext("lang").to_owned(),
})
.collect();
Ok((catalogs, langs))
}
@ -108,4 +105,4 @@ pub fn langs_filter(
langs: &Vec<LangCode>,
) -> tera::Result<Value> {
Ok(serde_json::to_value(langs).unwrap())
}
}

@ -2,7 +2,7 @@
extern crate rocket;
use poise::serenity_prelude::Http;
use rocket::{fs::{relative, FileServer}};
use rocket::fs::{relative, FileServer};
use rocket_dyn_templates::{tera, Template};
use sass_rocket_fairing::SassFairing;
use std::{collections::HashMap, env};
@ -58,7 +58,7 @@ async fn rocket() -> _ {
"langs",
move |value: &Value, args: &HashMap<String, Value>| {
langs_filter(value, args, &langs)
}
},
)
}))
.attach(SassFairing::default())

@ -3,7 +3,12 @@ use std::ops::Deref;
use rocket::{http::CookieJar, State};
use rocket_dyn_templates::{context, Template};
use crate::{models::{Challenge, Settings, User}, cookies::LANG_COOKIE, i18n::DEFAULT as DEFAULT_LANG, utils::AcceptLanguage};
use crate::{
cookies::LANG_COOKIE,
i18n::DEFAULT as DEFAULT_LANG,
models::{Challenge, Settings, User},
utils::AcceptLanguage,
};
#[get("/<challenge>")]
pub async fn get_challenge(

@ -27,4 +27,4 @@ macro_rules! header {
header!(Referer, "Referer");
header!(AcceptLanguage, "Accept-Language", Vec<String>, |header| {
accept_language::parse(header)
});
});

Loading…
Cancel
Save