translations #2
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
use log::error;
|
||||
use ovlach_data::cv::cv::CV;
|
||||
use rocket::{get, State, response::status::NotFound, http::Status};
|
||||
use rocket_dyn_templates::{Template, context};
|
||||
use rocket::{get, State, response::Redirect, http::Status};
|
||||
use rocket_dyn_templates::Template;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::{PresentationConfig, services::cv::fetch_cv_data_from_backend, CVBackendConfig};
|
||||
use crate::{PresentationConfig, services::cv::fetch_cv_data_from_backend, CVBackendConfig, tools::rocket::RequestLanguage};
|
||||
|
||||
#[derive(Serialize, Debug)]
|
||||
struct RootPage {
|
||||
@@ -14,14 +14,14 @@ struct RootPage {
|
||||
lang: String,
|
||||
}
|
||||
|
||||
#[get("/")]
|
||||
pub async fn index(presentation_config: &State<PresentationConfig>, cv_config: &State<CVBackendConfig>) -> Result<Template, Status> {
|
||||
#[get("/<language>")]
|
||||
pub async fn index(presentation_config: &State<PresentationConfig>, cv_config: &State<CVBackendConfig>, language: RequestLanguage) -> Result<Template, Status> {
|
||||
let context = match fetch_cv_data_from_backend(cv_config.cv_backend_path.clone()).await {
|
||||
Ok(cv) => RootPage {
|
||||
static_host: presentation_config.static_route.clone(),
|
||||
cv,
|
||||
download_cv_url: "FIXME!".to_string(),
|
||||
lang: "en".to_string(),
|
||||
lang: language.language,
|
||||
},
|
||||
Err(e) => {
|
||||
error!("Can't fetch CV data from backend {:?}", e);
|
||||
@@ -29,7 +29,12 @@ pub async fn index(presentation_config: &State<PresentationConfig>, cv_config: &
|
||||
}
|
||||
};
|
||||
|
||||
//return Templ;
|
||||
|
||||
Ok(Template::render("default", &context))
|
||||
}
|
||||
|
||||
|
||||
#[get("/")]
|
||||
pub fn index_without_lang() -> Redirect {
|
||||
// Default language is czech (TODO: config)
|
||||
Redirect::to(format!("{}/{}", "", "cs"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user