add translation files

This commit is contained in:
2025-08-03 09:47:43 +02:00
parent c1c659f771
commit d83a528a90
6 changed files with 359 additions and 7 deletions

View File

@@ -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 "

View File

@@ -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") {