pub struct EmbeddedI18n { /* private fields */ }Expand description
Explicit embedded localization context.
Construct this once during application startup, keep it in application state, and pass it to code that needs localization.
Implementations§
Source§impl EmbeddedI18n
impl EmbeddedI18n
Sourcepub fn try_new() -> Result<Self, EmbeddedInitError>
pub fn try_new() -> Result<Self, EmbeddedInitError>
Builds an embedded context without selecting a language.
Sourcepub fn try_new_with_language<L: Into<LanguageIdentifier>>(
lang: L,
) -> Result<Self, EmbeddedInitError>
pub fn try_new_with_language<L: Into<LanguageIdentifier>>( lang: L, ) -> Result<Self, EmbeddedInitError>
Builds an embedded context and selects the initial active language.
Sourcepub fn try_new_with_language_strict<L: Into<LanguageIdentifier>>(
lang: L,
) -> Result<Self, EmbeddedInitError>
pub fn try_new_with_language_strict<L: Into<LanguageIdentifier>>( lang: L, ) -> Result<Self, EmbeddedInitError>
Builds an embedded context and selects the initial active language, failing if any runtime module rejects the requested locale.
Sourcepub fn select_language<L: Into<LanguageIdentifier>>(
&self,
lang: L,
) -> Result<(), LocalizationError>
pub fn select_language<L: Into<LanguageIdentifier>>( &self, lang: L, ) -> Result<(), LocalizationError>
Selects the active language for this context.
Concurrent selections through cloned handles are serialized. A failed selection preserves the previously active language and selection policy.
Sourcepub fn select_language_strict<L: Into<LanguageIdentifier>>(
&self,
lang: L,
) -> Result<(), LocalizationError>
pub fn select_language_strict<L: Into<LanguageIdentifier>>( &self, lang: L, ) -> Result<(), LocalizationError>
Selects the active language for this context and fails if any runtime module rejects the requested locale.
Shares the same serialized transition as Self::select_language.
Sourcepub fn localize_message<T>(&self, message: &T) -> Stringwhere
T: FluentMessage + ?Sized,
pub fn localize_message<T>(&self, message: &T) -> Stringwhere
T: FluentMessage + ?Sized,
Renders a derived typed message through this context.