rust
Elnu 1 year ago
parent 3abc45cd4f
commit 857832e052

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

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

@ -3,7 +3,12 @@ use std::ops::Deref;
use rocket::{http::CookieJar, State}; use rocket::{http::CookieJar, State};
use rocket_dyn_templates::{context, Template}; 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>")] #[get("/<challenge>")]
pub async fn get_challenge( pub async fn get_challenge(

Loading…
Cancel
Save