add language functionality

This commit is contained in:
2025-08-03 10:16:24 +02:00
parent 2a27902e53
commit d97a6f6760

View File

@@ -2,7 +2,7 @@ use crate::model::client::Client;
use axum::{http::HeaderMap, routing::get, Router};
use axum_extra::extract::{cookie::Cookie, CookieJar};
use sqlx::{pool::PoolOptions, sqlite::SqliteConnectOptions, SqlitePool};
use std::{str::FromStr, sync::Arc};
use std::{fmt::Display, str::FromStr, sync::Arc};
use tower_http::services::ServeDir;
use uuid::Uuid;
@@ -28,7 +28,23 @@ enum Language {
English,
}
impl Display for Language {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Language::German => f.write_str("de"),
Language::English => f.write_str("en"),
}
}
}
impl Language {
pub(crate) fn next_language(&self) -> Self {
match self {
Language::German => Language::English,
Language::English => Language::German,
}
}
fn to_locale(&self) -> &'static str {
match self {
Language::German => "de",