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
impl ResourceManager
Sourcepub fn new(path_scheme: String) -> Self
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
Sourcepub fn get_bundle(
&self,
locales: Vec<LanguageIdentifier>,
resource_ids: Vec<String>,
) -> Result<FluentBundle<&FluentResource>, Vec<ResourceManagerError>>
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.
Sourcepub fn get_bundles(
&self,
locales: Vec<LanguageIdentifier>,
resource_ids: Vec<String>,
) -> impl Iterator<Item = Result<FluentBundle<&FluentResource>, Vec<ResourceManagerError>>>
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.