GettextLanguageLoader

Struct GettextLanguageLoader 

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

LanguageLoader implementation for the gettext localization system.

⚠️ This API requires the following crate features to be activated: gettext-system.

Implementations§

Source§

impl GettextLanguageLoader

Source

pub fn new(module: &'static str, fallback_language: LanguageIdentifier) -> Self

Create a new GettextLanguageLoader.

§Example
use i18n_embed::gettext::GettextLanguageLoader;

GettextLanguageLoader::new(module_path!(), "en".parse().unwrap());

Trait Implementations§

Source§

impl Debug for GettextLanguageLoader

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl LanguageLoader for GettextLanguageLoader

Source§

fn fallback_language(&self) -> &LanguageIdentifier

The fallback language for the module this loader is responsible for.

Source§

fn domain(&self) -> &'static str

The domain for the translation that this loader is associated with.

Source§

fn language_file_name(&self) -> String

The language file name to use for this loader’s domain.

Source§

fn current_language(&self) -> LanguageIdentifier

Get the language which is currently loaded for this loader.

Source§

fn load_languages( &self, i18n_assets: &dyn I18nAssets, language_ids: &[LanguageIdentifier], ) -> Result<(), I18nEmbedError>

Load the languages language_ids using the resources packaged in the i18n_assets in order of fallback preference. This also sets the LanguageLoader::current_language() to the first in the language_ids slice. You can use select() to determine which fallbacks are actually available for an arbitrary slice of preferences.

Note: Gettext doesn’t support loading multiple languages as multiple fallbacks. We only load the first of the requested languages, and the fallback is the src language.

Source§

fn reload(&self, i18n_assets: &dyn I18nAssets) -> Result<(), I18nEmbedError>

Reload the currently loaded languages.
Source§

fn language_files<'a>( &self, language_id: &LanguageIdentifier, i18n_assets: &'a dyn I18nAssets, ) -> (String, Vec<Cow<'a, [u8]>>)

The computed path to the language files, and data contained within the files at that path itself if they exist. There can be multiple files at a given path, in order of preference from high to low.
Source§

fn available_languages( &self, i18n_assets: &dyn I18nAssets, ) -> Result<Vec<LanguageIdentifier>, I18nEmbedError>

Calculate the languages which are available to be loaded.
Source§

fn load_available_languages( &self, i18n_assets: &dyn I18nAssets, ) -> Result<(), I18nEmbedError>

Load all available languages with LanguageLoader::load_languages().
Source§

fn load_fallback_language( &self, i18n_assets: &dyn I18nAssets, ) -> Result<(), I18nEmbedError>

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