[][src]Struct i18n_embed::fluent::FluentLanguageLoader

pub struct FluentLanguageLoader { /* fields omitted */ }

LanguageLoader implemenation for the fluent localization system. Also provides methods to access localizations which have been loaded.

⚠️ This API requires the following crate features to be activated: fluent-system.

Implementations

impl FluentLanguageLoader[src]

pub fn new<S: Into<String>>(
    domain: S,
    fallback_language: LanguageIdentifier
) -> Self
[src]

Create a new FluentLanguageLoader, which loads messages for the specified domain, and relies on the specified fallback_language for any messages that do not exist for the current language.

pub fn get(&self, message_id: &str) -> String[src]

Get a localized message referenced by the message_id.

pub fn get_args_concrete<'source>(
    &self,
    message_id: &str,
    args: HashMap<&'source str, FluentValue<'source>>
) -> String
[src]

A non-generic version of FluentLanguageLoader::get_args().

pub fn get_args_fluent<'args>(
    &self,
    message_id: &str,
    args: Option<&'args FluentArgs<'args>>
) -> String
[src]

A non-generic version of FluentLanguageLoader::get_args() accepting [FluentArgs] instead of a HashMap.

pub fn get_args<'a, S, V>(&self, id: &str, args: HashMap<S, V>) -> String where
    S: Into<Cow<'a, str>> + Clone,
    V: Into<FluentValue<'a>> + Clone
[src]

Get a localized message referenced by the message_id, and formatted with the specified args.

pub fn has(&self, message_id: &str) -> bool[src]

Returns true if a message with the specified message_id is available in any of the languages currently loaded (including the fallback language).

pub fn with_fluent_message<OUT, C>(
    &self,
    message_id: &str,
    closure: C
) -> Option<OUT> where
    C: Fn(FluentMessage<'_>) -> OUT, 
[src]

Run the closure with the message that matches the specified message_id (if it is available in any of the languages currently loaded, including the fallback language). Returns Some of whatever whatever the closure returns, or None if no messages were found matching the message_id.

pub fn with_message_iter<OUT, C>(
    &self,
    language: &LanguageIdentifier,
    closure: C
) -> OUT where
    C: Fn(&mut dyn Iterator<Item = &Message<&str>>) -> OUT, 
[src]

Runs the provided closure with an iterator over the messages available for the specified language. There may be duplicate messages when they are duplicated in resources applicable to the language. Returns the result of the closure.

Trait Implementations

impl Debug for FluentLanguageLoader[src]

impl LanguageLoader for FluentLanguageLoader[src]

fn fallback_language(&self) -> &LanguageIdentifier[src]

The fallback language for the module this loader is responsible for.

fn domain(&self) -> &str[src]

The domain for the translation that this loader is associated with.

fn language_file_name(&self) -> String[src]

The language file name to use for this loader.

fn current_language(&self) -> LanguageIdentifier[src]

Get the language which is currently loaded for this loader.

fn load_languages(
    &self,
    i18n_assets: &dyn I18nAssets,
    language_ids: &[&LanguageIdentifier]
) -> Result<(), I18nEmbedError>
[src]

Load the languages language_ids using the resources packaged in the i18n_assets in order of fallback preference. This also sets the LanguageLoader::current_language() to the first in the language_ids slice. You can use select() to determine which fallbacks are actually available for an arbitrary slice of preferences.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.