pub struct I18nContext { /* private fields */ }Expand description
国际化上下文
Implementations§
Source§impl I18nContext
impl I18nContext
Sourcepub fn with_cache_capacity(
translator: Box<dyn TranslationProvider + Send + Sync>,
capacity: usize,
) -> Self
pub fn with_cache_capacity( translator: Box<dyn TranslationProvider + Send + Sync>, capacity: usize, ) -> Self
创建带有自定义缓存容量的国际化上下文
Sourcepub fn t_with_args(
&mut self,
key: &str,
args: Option<&HashMap<String, String>>,
) -> String
pub fn t_with_args( &mut self, key: &str, args: Option<&HashMap<String, String>>, ) -> String
翻译带参数的键
Sourcepub fn t_batch(
&mut self,
keys: &[(String, Option<HashMap<String, String>>)],
) -> Vec<String>
pub fn t_batch( &mut self, keys: &[(String, Option<HashMap<String, String>>)], ) -> Vec<String>
批量翻译
Sourcepub fn get_locale(&self) -> &str
pub fn get_locale(&self) -> &str
获取当前语言
Sourcepub fn set_locale(&mut self, locale: &str)
pub fn set_locale(&mut self, locale: &str)
设置当前语言
Sourcepub fn clear_cache(&mut self)
pub fn clear_cache(&mut self)
清除翻译缓存
Sourcepub fn cache_size(&self) -> usize
pub fn cache_size(&self) -> usize
获取缓存大小
Trait Implementations§
Auto Trait Implementations§
impl Freeze for I18nContext
impl !RefUnwindSafe for I18nContext
impl Send for I18nContext
impl Sync for I18nContext
impl Unpin for I18nContext
impl UnsafeUnpin for I18nContext
impl !UnwindSafe for I18nContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more