Skip to main content

Localizations

Struct Localizations 

Source
pub struct Localizations;
Expand description

Embedded Fluent resources shipped with the crate.

The struct implements RustEmbed, allowing callers to seed a FluentLanguageLoader with the bundled locale files.

§Examples

let mut loader = fluent_language_loader!();
let selected = i18n_embed::select(&loader, &Localizations, &[langid!("en-US")]).unwrap();
assert!(selected.contains(&langid!("en-US")));

Implementations§

Source§

impl Localizations

Source

pub fn get(file_path: &str) -> Option<EmbeddedFile>

Get an embedded file and its metadata.

Source

pub fn iter() -> impl Iterator<Item = Cow<'static, str>>

Iterates over the file paths in the folder.

Trait Implementations§

Source§

impl RustEmbed for Localizations

Available on debug-assertions enabled only.
Source§

fn get(file_path: &str) -> Option<EmbeddedFile>

Get an embedded file and its metadata. Read more
Source§

fn iter() -> Filenames

Iterates over the file paths in the folder. Read more

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> I18nAssets for T
where T: RustEmbed,

Source§

fn get_files(&self, file_path: &str) -> Vec<Cow<'_, [u8]>>

Get localization asset files that correspond to the specified file_path. Returns an empty Vec if the asset does not exist, or unable to obtain the asset due to a non-critical error.
Source§

fn filenames_iter(&self) -> Box<dyn Iterator<Item = String>>

Get an iterator over the file paths of the localization assets. There may be duplicates where multiple files exist for the same file path.
Source§

fn subscribe_changed( &self, changed: Arc<dyn Fn() + Send + Sync>, ) -> Result<Box<dyn Watcher + Send + Sync>, I18nEmbedError>

A method to allow users of this trait to subscribe to change events, and reload assets when they have changed. The subscription will be cancelled when the returned Watcher is dropped. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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.