Trait i18n_embed::LanguageRequester[][src]

pub trait LanguageRequester<'a> {
    fn add_listener(&mut self, listener: Weak<dyn Localizer>);
fn add_listener_ref(&mut self, listener: &'a dyn Localizer);
fn poll(&mut self) -> Result<(), I18nEmbedError>;
fn set_language_override(
        &mut self,
        language_override: Option<LanguageIdentifier>
    ) -> Result<(), I18nEmbedError>;
fn requested_languages(&self) -> Vec<LanguageIdentifier>;
fn available_languages(
        &self
    ) -> Result<Vec<LanguageIdentifier>, I18nEmbedError>;
fn current_languages(&self) -> HashMap<String, LanguageIdentifier>; }
Expand description

A trait used by I18nAssets to ascertain which languages are being requested.

Required methods

Add a listener to this LanguageRequester. When the system reports that the currently requested languages has changed, each listener will have its Localizer#select() method called. Weak is used so that when the Arc that it references is dropped, the listener will also be removed next time this requester is polled/updates.

If you haven’t already selected a language for the localizer you are adding here, you may want to manually call #poll() after adding the listener/s.

Add a listener to this LanguageRequester. When the system reports that the currently requested languages has changed, each listener will have its Localizer#select() method called. As opposed to LanguageRequester::add_listener(), this listener will not be removed.

If you haven’t already selected a language for the localizer you are adding here, you may want to manually call #poll() after adding the listener/s.

Poll the system’s currently selected language, and call Localizer#select() on each of the listeners.

NOTE: Support for this across systems currently varies, it may not change when the system requested language changes during runtime without restarting your application. In the future some platforms may also gain support for automatic triggering when the requested display language changes.

Override the languages fed to the Localizer listeners during a #poll(). Set this as None to disable the override.

The currently requested languages.

The languages reported to be available in the listener Localizers.

The languages currently loaded, keyed by the LanguageLoader::domain().

Implementors