[−][src]Struct i18n_embed::fluent::FluentLanguageLoader
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]
domain: S,
fallback_language: LanguageIdentifier
) -> Self
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]
&self,
message_id: &str,
args: HashMap<&'source str, FluentValue<'source>>
) -> String
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]
&self,
message_id: &str,
args: Option<&'args FluentArgs<'args>>
) -> String
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]
S: Into<Cow<'a, str>> + Clone,
V: Into<FluentValue<'a>> + Clone,
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]
&self,
message_id: &str,
closure: C
) -> Option<OUT> where
C: Fn(FluentMessage<'_>) -> OUT,
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]
&self,
language: &LanguageIdentifier,
closure: C
) -> OUT where
C: Fn(&mut dyn Iterator<Item = &Message<&str>>) -> OUT,
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]
&self,
i18n_assets: &dyn I18nAssets,
language_ids: &[&LanguageIdentifier]
) -> Result<(), I18nEmbedError>
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.
fn language_file<'a>(
&self,
language_id: &LanguageIdentifier,
i18n_assets: &'a dyn I18nAssets
) -> (String, Option<Cow<'a, [u8]>>)
[src]
&self,
language_id: &LanguageIdentifier,
i18n_assets: &'a dyn I18nAssets
) -> (String, Option<Cow<'a, [u8]>>)
fn available_languages(
&self,
i18n_assets: &dyn I18nAssets
) -> Result<Vec<LanguageIdentifier>, I18nEmbedError>
[src]
&self,
i18n_assets: &dyn I18nAssets
) -> Result<Vec<LanguageIdentifier>, I18nEmbedError>
Auto Trait Implementations
impl !RefUnwindSafe for FluentLanguageLoader
impl Send for FluentLanguageLoader
impl Sync for FluentLanguageLoader
impl Unpin for FluentLanguageLoader
impl !UnwindSafe for FluentLanguageLoader
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,