dioxus-i18n 🌍
i18n integration for Dioxus apps based on the Project Fluent.
This crate used to be in the Dioxus SDK.
Support
- Dioxus v0.6 🧬
- Renderers:
- Both WASM and native targets
Example:
# en-US.ftl
hello = Hello, {$name}!
fn app() -> Element {
let i18 = use_init_i18n(|| {
I18nConfig::new(langid!("en-US"))
.with_locale(( langid!("en-US"),
include_str!("./en-US.ftl")
))
.with_locale(( langid!("es-ES"),
PathBuf::from("./es-ES.ftl"),
))
.with_locale(( langid!("en"), include_str!("./en-US.ftl") ))
.with_locale(Locale::new_static( langid!("en-US"),
include_str!("./en-US.ftl"),
))
.with_locale(Locale::new_dynamic( langid!("es-ES"),
PathBuf::from("./es-ES.ftl"),
))
});
rsx!(
label { { t!("hello", name: "World") } }
)
}
Further examples
The examples folder contains a number of working examples:
- Desktop examples:
- Configuration variants:
- Fluent grammer:
Development
cargo build --target wasm32-unknown-unknown
cargo test
MIT License