Skip to main content

TranslationProvider

Trait TranslationProvider 

Source
pub trait TranslationProvider {
    // Required methods
    fn translate(
        &self,
        key: &str,
        args: Option<&HashMap<String, String>>,
        locale: &str,
    ) -> Result<String, I18nError>;
    fn get_locale(&self) -> &str;
    fn set_locale(&mut self, locale: &str);
    fn clone_box(&self) -> Box<dyn TranslationProvider + Send + Sync>;
}
Expand description

翻译提供者 trait

Required Methods§

Source

fn translate( &self, key: &str, args: Option<&HashMap<String, String>>, locale: &str, ) -> Result<String, I18nError>

翻译一个键

Source

fn get_locale(&self) -> &str

获取当前语言

Source

fn set_locale(&mut self, locale: &str)

设置当前语言

Source

fn clone_box(&self) -> Box<dyn TranslationProvider + Send + Sync>

克隆翻译提供者

Implementors§