fluent_templates

Trait Loader

Source
pub trait Loader {
    // Required methods
    fn lookup_complete(
        &self,
        lang: &LanguageIdentifier,
        text_id: &str,
        args: Option<&HashMap<Cow<'static, str>, FluentValue<'_>>>,
    ) -> String;
    fn try_lookup_complete(
        &self,
        lang: &LanguageIdentifier,
        text_id: &str,
        args: Option<&HashMap<Cow<'static, str>, FluentValue<'_>>>,
    ) -> Option<String>;
    fn locales(&self) -> Box<dyn Iterator<Item = &LanguageIdentifier> + '_>;

    // Provided methods
    fn lookup(&self, lang: &LanguageIdentifier, text_id: &str) -> String { ... }
    fn lookup_with_args(
        &self,
        lang: &LanguageIdentifier,
        text_id: &str,
        args: &HashMap<Cow<'static, str>, FluentValue<'_>>,
    ) -> String { ... }
    fn try_lookup(
        &self,
        lang: &LanguageIdentifier,
        text_id: &str,
    ) -> Option<String> { ... }
    fn try_lookup_with_args(
        &self,
        lang: &LanguageIdentifier,
        text_id: &str,
        args: &HashMap<Cow<'static, str>, FluentValue<'_>>,
    ) -> Option<String> { ... }
}
Expand description

A loader capable of looking up Fluent keys given a language.

Required Methods§

Source

fn lookup_complete( &self, lang: &LanguageIdentifier, text_id: &str, args: Option<&HashMap<Cow<'static, str>, FluentValue<'_>>>, ) -> String

Look up text_id for lang in Fluent, using any args if provided.

Source

fn try_lookup_complete( &self, lang: &LanguageIdentifier, text_id: &str, args: Option<&HashMap<Cow<'static, str>, FluentValue<'_>>>, ) -> Option<String>

Look up text_id for lang in Fluent, using any args if provided.

Source

fn locales(&self) -> Box<dyn Iterator<Item = &LanguageIdentifier> + '_>

Returns an Iterator over the locales that are present.

Provided Methods§

Source

fn lookup(&self, lang: &LanguageIdentifier, text_id: &str) -> String

Look up text_id for lang in Fluent.

Source

fn lookup_with_args( &self, lang: &LanguageIdentifier, text_id: &str, args: &HashMap<Cow<'static, str>, FluentValue<'_>>, ) -> String

Look up text_id for lang with args in Fluent.

Source

fn try_lookup(&self, lang: &LanguageIdentifier, text_id: &str) -> Option<String>

Look up text_id for lang in Fluent.

Source

fn try_lookup_with_args( &self, lang: &LanguageIdentifier, text_id: &str, args: &HashMap<Cow<'static, str>, FluentValue<'_>>, ) -> Option<String>

Look up text_id for lang with args in Fluent.

Implementations on Foreign Types§

Source§

impl<'a, L> Loader for &'a L
where L: Loader,

Source§

fn lookup_complete( &self, lang: &LanguageIdentifier, text_id: &str, args: Option<&HashMap<Cow<'static, str>, FluentValue<'_>>>, ) -> String

Source§

fn try_lookup_complete( &self, lang: &LanguageIdentifier, text_id: &str, args: Option<&HashMap<Cow<'static, str>, FluentValue<'_>>>, ) -> Option<String>

Source§

fn locales(&self) -> Box<dyn Iterator<Item = &LanguageIdentifier> + '_>

Source§

impl<L> Loader for Arc<L>
where L: Loader,

Source§

fn lookup_complete( &self, lang: &LanguageIdentifier, text_id: &str, args: Option<&HashMap<Cow<'static, str>, FluentValue<'_>>>, ) -> String

Source§

fn try_lookup_complete( &self, lang: &LanguageIdentifier, text_id: &str, args: Option<&HashMap<Cow<'static, str>, FluentValue<'_>>>, ) -> Option<String>

Source§

fn locales(&self) -> Box<dyn Iterator<Item = &LanguageIdentifier> + '_>

Implementors§