added i18n
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user