pub struct ArcLoader { /* private fields */ }
Expand description
A loader that uses Arc<FluentResource>
as its backing storage. This is
mainly useful for when you need to load fluent at run time. You can
configure the initialisation with ArcLoaderBuilder
.
use fluent_templates::ArcLoader;
let loader = ArcLoader::builder("locales/", unic_langid::langid!("en-US"))
.shared_resources(Some(&["locales/core.ftl".into()]))
.customize(|bundle| bundle.set_use_isolating(false))
.build()
.unwrap();
Implementations§
Source§impl ArcLoader
impl ArcLoader
Sourcepub fn builder<P: AsRef<Path> + ?Sized>(
location: &P,
fallback: LanguageIdentifier,
) -> ArcLoaderBuilder<'_, '_>
pub fn builder<P: AsRef<Path> + ?Sized>( location: &P, fallback: LanguageIdentifier, ) -> ArcLoaderBuilder<'_, '_>
Creates a new ArcLoaderBuilder
Sourcepub fn lookup_single_language<T: AsRef<str>>(
&self,
lang: &LanguageIdentifier,
text_id: &str,
args: Option<&HashMap<T, FluentValue<'_>>>,
) -> Result<String, LookupError>
pub fn lookup_single_language<T: AsRef<str>>( &self, lang: &LanguageIdentifier, text_id: &str, args: Option<&HashMap<T, FluentValue<'_>>>, ) -> Result<String, LookupError>
Convenience function to look up a string for a single language
Sourcepub fn lookup_no_default_fallback<S: AsRef<str>>(
&self,
lang: &LanguageIdentifier,
text_id: &str,
args: Option<&HashMap<S, FluentValue<'_>>>,
) -> Option<String>
pub fn lookup_no_default_fallback<S: AsRef<str>>( &self, lang: &LanguageIdentifier, text_id: &str, args: Option<&HashMap<S, FluentValue<'_>>>, ) -> Option<String>
Convenience function to look up a string without falling back to the default fallback language
Sourcepub fn fallback(&self) -> &LanguageIdentifier
pub fn fallback(&self) -> &LanguageIdentifier
Return the fallback language
Trait Implementations§
Source§impl Loader for ArcLoader
impl Loader for ArcLoader
Source§fn lookup_complete(
&self,
lang: &LanguageIdentifier,
text_id: &str,
args: Option<&HashMap<Cow<'static, str>, FluentValue<'_>>>,
) -> String
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>
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> + '_>
fn locales(&self) -> Box<dyn Iterator<Item = &LanguageIdentifier> + '_>
Returns an Iterator over the locales that are present.
Source§fn lookup(&self, lang: &LanguageIdentifier, text_id: &str) -> String
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
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>
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>
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.Auto Trait Implementations§
impl Freeze for ArcLoader
impl !RefUnwindSafe for ArcLoader
impl Send for ArcLoader
impl Sync for ArcLoader
impl Unpin for ArcLoader
impl !UnwindSafe for ArcLoader
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more