feat(i18n): add internationalization with DE, FR, ES, PT translations
All checks were successful
CI / Format (push) Successful in 30s
CI / Clippy (push) Successful in 2m36s
CI / Security Audit (push) Has been skipped
CI / Tests (push) Has been skipped
CI / Format (pull_request) Successful in 3s
CI / Clippy (pull_request) Successful in 2m15s
CI / Security Audit (pull_request) Has been skipped
CI / Tests (pull_request) Has been skipped
CI / Deploy (push) Has been skipped
CI / Deploy (pull_request) Has been skipped
All checks were successful
CI / Format (push) Successful in 30s
CI / Clippy (push) Successful in 2m36s
CI / Security Audit (push) Has been skipped
CI / Tests (push) Has been skipped
CI / Format (pull_request) Successful in 3s
CI / Clippy (pull_request) Successful in 2m15s
CI / Security Audit (pull_request) Has been skipped
CI / Tests (pull_request) Has been skipped
CI / Deploy (push) Has been skipped
CI / Deploy (pull_request) Has been skipped
Add a compile-time i18n system with 270 translation keys across 5 locales (EN, DE, FR, ES, PT). Translations are embedded via include_str! and parsed lazily into flat HashMaps with English fallback for missing keys. - Add src/i18n module with Locale enum, t()/tw() lookup functions, and tests - Add JSON translation files for all 5 locales under assets/i18n/ - Provide locale Signal via Dioxus context in App, persisted to localStorage - Replace all hardcoded UI strings across 33 component/page files - Add compact locale picker (globe icon + ISO alpha-2 code) in sidebar header - Add click-outside backdrop dismissal for locale dropdown Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
22
src/app.rs
22
src/app.rs
@@ -1,3 +1,4 @@
|
||||
use crate::i18n::Locale;
|
||||
use crate::{components::*, pages::*};
|
||||
use dioxus::prelude::*;
|
||||
|
||||
@@ -61,8 +62,29 @@ const GOOGLE_FONTS: &str = "https://fonts.googleapis.com/css2?\
|
||||
display=swap";
|
||||
|
||||
/// Root application component. Loads global assets and mounts the router.
|
||||
///
|
||||
/// Provides a `Signal<Locale>` context that all child components can read
|
||||
/// via `use_context::<Signal<Locale>>()` to access the current locale.
|
||||
/// The locale is persisted in `localStorage` under `"certifai_locale"`.
|
||||
#[component]
|
||||
pub fn App() -> Element {
|
||||
// Read persisted locale from localStorage on first render.
|
||||
let initial_locale = {
|
||||
#[cfg(feature = "web")]
|
||||
{
|
||||
web_sys::window()
|
||||
.and_then(|w| w.local_storage().ok().flatten())
|
||||
.and_then(|s| s.get_item("certifai_locale").ok().flatten())
|
||||
.map(|code| Locale::from_code(&code))
|
||||
.unwrap_or_default()
|
||||
}
|
||||
#[cfg(not(feature = "web"))]
|
||||
{
|
||||
Locale::default()
|
||||
}
|
||||
};
|
||||
use_context_provider(|| Signal::new(initial_locale));
|
||||
|
||||
rsx! {
|
||||
// Seggwat feedback widget
|
||||
document::Script {
|
||||
|
||||
Reference in New Issue
Block a user