added i18n

This commit is contained in:
2026-05-07 23:19:22 +02:00
parent 4e450430f6
commit e28e844967
11 changed files with 637 additions and 87 deletions

View File

@@ -1,5 +1,6 @@
use axum::{Router, routing::get};
use clap::Parser;
use fluent_templates::FluentLoader;
use lazy_static::lazy_static;
use std::{
sync::Arc,
@@ -10,8 +11,12 @@ use tokio::sync::RwLock;
mod handlers;
use handlers::home_handler;
mod i18n;
use crate::handlers::{Report, analytics_handler, report_details_handler};
use crate::{
handlers::{Report, analytics_handler, report_details_handler, set_lang_handler},
i18n::LOCALES,
};
lazy_static! {
pub static ref TEMPLATES: Tera = {
@@ -27,6 +32,7 @@ lazy_static! {
),
])
.unwrap();
tera.register_function("fluent", FluentLoader::new(&*LOCALES));
tera
};
}
@@ -76,6 +82,7 @@ async fn main() -> anyhow::Result<()> {
.route("/", get(home_handler))
.route("/report/{id}", get(report_details_handler))
.route("/analytics", get(analytics_handler))
.route("/set-lang/{lang}", get(set_lang_handler))
.with_state(shared_state);
let addr = if cli.host {