| Crates.io | dioxus-i18n |
| lib.rs | dioxus-i18n |
| version | 0.4.3 |
| created_at | 2024-08-31 13:32:55.301795+00 |
| updated_at | 2025-03-16 09:17:02.374813+00 |
| description | i18n integration for Dioxus apps based on Fluent Project. |
| homepage | |
| repository | https://github.com/dioxus-community/dioxus-i18n |
| max_upload_size | |
| id | 1358856 |
| size | 292,887 |
i18n integration for Dioxus apps based on the Project Fluent.
This crate used to be in the Dioxus SDK.
# en-US.ftl
hello = Hello, {$name}!
// main.rs
fn app() -> Element {
let i18 = use_init_i18n(|| {
I18nConfig::new(langid!("en-US"))
// implicit [`Locale`]
.with_locale(( // Embed
langid!("en-US"),
include_str!("./en-US.ftl")
))
.with_locale(( // Load at launch
langid!("es-ES"),
PathBuf::from("./es-ES.ftl"),
))
.with_locale(( // Locales will share duplicated locale_resources
langid!("en"), // which is useful to assign a specific region for
include_str!("./en-US.ftl") // the primary language
))
// explicit [`Locale`]
.with_locale(Locale::new_static( // Embed
langid!("en-US"),
include_str!("./en-US.ftl"),
))
.with_locale(Locale::new_dynamic( // Load at launch
langid!("es-ES"),
PathBuf::from("./es-ES.ftl"),
))
});
rsx!(
label { { t!("hello", name: "World") } }
)
}
The examples folder contains a number of working examples:
# Checks clean compile against `#[cfg(not(target_arch = "wasm32"))]`
cargo build --target wasm32-unknown-unknown
# Runs all tests
cargo test