ResourceManager

Struct ResourceManager 

Source
pub struct ResourceManager { /* private fields */ }
Expand description

ResourceManager provides a standalone solution for managing localization resources which can be used by fluent-fallback or other higher level bindings.

Implementations§

Source§

impl ResourceManager

Source

pub fn new(path_scheme: String) -> Self

Create a new and empty ResourceManager. As resources are added they will be retained in the resources FrozenMap. The path_scheme argument defines how the files are organized.

For instance "./translations/{locale}/{res_id}" will load files with the following structure:

. └── translations     ├── en-US     │   ├── app.ftl     │   └── errors.ftl     └── pl     ├── app.ftl     └── errors.ftl

Source

pub fn get_bundle( &self, locales: Vec<LanguageIdentifier>, resource_ids: Vec<String>, ) -> Result<FluentBundle<&FluentResource>, Vec<ResourceManagerError>>

Gets a FluentBundle from a list of resources. The bundle will only contain the resources from the first locale in the locales list. The other locales will be stored in the FluentBundle and will only be used for custom formatters such date time format, or plural rules. The message formatting will not fall back to other locales.

Source

pub fn get_bundles( &self, locales: Vec<LanguageIdentifier>, resource_ids: Vec<String>, ) -> impl Iterator<Item = Result<FluentBundle<&FluentResource>, Vec<ResourceManagerError>>>

Returns an iterator for a FluentBundle for each locale provided. Each iteration will load all of the resources for that single locale. i18n formatters such as date time format and plural rules will ignore the list of locales, unlike get_bundle and only use the single locale of the bundle.

Trait Implementations§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.