Struct fluent_templates::ArcLoader

source ·
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

source

pub fn builder<P: AsRef<Path> + ?Sized>( location: &P, fallback: LanguageIdentifier ) -> ArcLoaderBuilder<'_, '_>

Creates a new ArcLoaderBuilder

source

pub fn lookup_single_language<T: AsRef<str>>( &self, lang: &LanguageIdentifier, text_id: &str, args: Option<&HashMap<T, FluentValue<'_>>> ) -> Option<String>

Convenience function to look up a string for a single language

source

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

Trait Implementations§

source§

impl Loader for ArcLoader

source§

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

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

fn try_lookup_complete<T: AsRef<str>>( &self, lang: &LanguageIdentifier, text_id: &str, args: Option<&HashMap<T, 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.
source§

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

Look up text_id for lang in Fluent.
source§

fn lookup_with_args<T: AsRef<str>>( &self, lang: &LanguageIdentifier, text_id: &str, args: &HashMap<T, 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<T: AsRef<str>>( &self, lang: &LanguageIdentifier, text_id: &str, args: &HashMap<T, FluentValue<'_>> ) -> Option<String>

Look up text_id for lang with args in Fluent.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.