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§
Sourcefn translate(
&self,
key: &str,
args: Option<&HashMap<String, String>>,
locale: &str,
) -> Result<String, I18nError>
fn translate( &self, key: &str, args: Option<&HashMap<String, String>>, locale: &str, ) -> Result<String, I18nError>
翻译一个键
Sourcefn get_locale(&self) -> &str
fn get_locale(&self) -> &str
获取当前语言
Sourcefn set_locale(&mut self, locale: &str)
fn set_locale(&mut self, locale: &str)
设置当前语言