add translation files
This commit is contained in:
@@ -5,8 +5,11 @@ use maud::{html, Markup};
|
||||
|
||||
pub(super) async fn index(cookies: CookieJar, headers: HeaderMap) -> Markup {
|
||||
let lang = language(&cookies, &headers);
|
||||
|
||||
rust_i18n::set_locale(lang.to_locale());
|
||||
|
||||
new(html! {
|
||||
h1 { "Digital Shadows" }
|
||||
h1 { (t!("digital_shadows")) }
|
||||
hgroup {
|
||||
h2 {
|
||||
"Who owns your "
|
||||
|
14
src/main.rs
14
src/main.rs
@@ -6,6 +6,11 @@ use std::{str::FromStr, sync::Arc};
|
||||
use tower_http::services::ServeDir;
|
||||
use uuid::Uuid;
|
||||
|
||||
#[macro_use]
|
||||
extern crate rust_i18n;
|
||||
|
||||
i18n!("locales", fallback = "en");
|
||||
|
||||
mod game;
|
||||
mod index;
|
||||
pub(crate) mod language;
|
||||
@@ -23,6 +28,15 @@ enum Language {
|
||||
English,
|
||||
}
|
||||
|
||||
impl Language {
|
||||
fn to_locale(&self) -> &'static str {
|
||||
match self {
|
||||
Language::German => "de",
|
||||
Language::English => "en",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<String> for Language {
|
||||
fn from(value: String) -> Self {
|
||||
if value.starts_with("de") {
|
||||
|
Reference in New Issue
Block a user