pub trait TranslationsManager: Debug + Clone + Send + Sync {
    fn get_translator_for_locale<'life0, 'async_trait>(
        &'life0 self,
        locale: String
    ) -> Pin<Box<dyn Future<Output = Result<Translator, TranslationsManagerError>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
; fn get_translations_str_for_locale<'life0, 'async_trait>(
        &'life0 self,
        locale: String
    ) -> Pin<Box<dyn Future<Output = Result<String, TranslationsManagerError>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
; fn new_dummy() -> Self; }
Expand description

A trait for systems that manage where to put translations. At simplest, we’ll just write them to static files, but they might also be stored in a CMS. It is strongly advised that any implementations use some form of caching, guided by FsTranslationsManager.

Required Methods

Gets a translator for the given locale. If i18n is disabled, this should return an empty string.

Gets the translations in string format for the given locale (avoids deserialize-then-serialize). If i18n is disabled, this should return a translator for the given locale with no translation string.

Creates a new instance of this translations manager, as a dummy for apps that aren’t using i18n at all. This may seem pointless, but it’s needed for trait completeness and to support certain engine middleware use-cases. In general, this should simply create an empty instance of the manager, and all other functions should do nothing if it is empty.

Notably, this must be synchronous.

Implementors