9 unstable releases (3 breaking)

new 0.4.2 Feb 7, 2025
0.4.1 Feb 2, 2025
0.3.0 Dec 10, 2024
0.2.5 Sep 10, 2024
0.1.0 Aug 31, 2024

#49 in Accessibility

Download history 14/week @ 2024-10-18 28/week @ 2024-10-25 40/week @ 2024-11-01 35/week @ 2024-11-08 82/week @ 2024-11-15 60/week @ 2024-11-22 17/week @ 2024-11-29 212/week @ 2024-12-06 150/week @ 2024-12-13 98/week @ 2024-12-20 67/week @ 2024-12-27 68/week @ 2025-01-03 109/week @ 2025-01-10 87/week @ 2025-01-17 82/week @ 2025-01-24 266/week @ 2025-01-31

551 downloads per month

MIT license

65KB
599 lines

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}!
// 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") } }
    )
}

Development

# Checks clean compile against `#[cfg(not(target_arch = "wasm32"))]`
cargo build --target wasm32-unknown-unknown

# Runs all tests
cargo test

MIT License

Dependencies

~5–13MB
~142K SLoC