Files
pruefwerk/compliance-dashboard/src/components/lang_toggle.rs
T
sharang 5efc267075
CI / Check (push) Skipped
CI / Detect Changes (push) Successful in 4s
CI / Deploy Agent (push) Skipped
CI / Deploy Docs (push) Skipped
CI / Deploy MCP (push) Skipped
CI / Deploy Dashboard (push) Successful in 10m0s
feat(dashboard): German by default, English switchable (#336) (#342)
2026-09-23 13:46:15 +00:00

32 lines
967 B
Rust

use dioxus::prelude::*;
use dioxus_free_icons::icons::bs_icons::BsTranslate;
use dioxus_free_icons::Icon;
use crate::i18n::texts::nav;
use crate::i18n::{set_lang, use_lang};
/// Sidebar-footer switch between German and English. Shows the language it
/// switches to, so a reader who does not understand the current one can still
/// find it.
#[component]
pub fn LangToggle(collapsed: bool) -> Element {
let lang = use_lang();
let current = lang();
let target = current.other();
let title = nav::SWITCH_LANGUAGE.get(current);
rsx! {
button {
class: "theme-toggle",
r#type: "button",
title: "{title}",
"aria-label": "{title}",
onclick: move |_| set_lang(lang, target),
Icon { icon: BsTranslate, width: 16, height: 16 }
if !collapsed {
span { class: "theme-toggle-label", "{target.code().to_uppercase()}" }
}
}
}
}