Skip to main content

use_share_i18n

Function use_share_i18n 

pub fn use_share_i18n(i18n: impl FnOnce() -> I18n)
Available on crate feature i18n only.
Expand description

Provide an existing I18n instance to descendant components.

This is useful for sharing the same global i18n state across different parts of the component tree or across multiple windows. Typically paired with I18n::create_global.

struct MyApp {
    i18n: I18n,
}

impl App for MyApp {
    fn render(&self) -> impl IntoElement {
        // Make the I18n instance available to all descendant components
        use_share_i18n(move || self.i18n);

        rect().child(t!("hello_world"))
    }
}