pub struct Localizer<'this> { /* private fields */ }Expand description
Heart and soul of this crated. Intended to be initialized once.
Implementations§
Source§impl<'this> Localizer<'this>
impl<'this> Localizer<'this>
Sourcepub fn new(locales_path: impl AsRef<Path>) -> Self
pub fn new(locales_path: impl AsRef<Path>) -> Self
Creates new Localizer and searches for available locales in specified folder.
Sourcepub fn precache_all(self) -> Self
pub fn precache_all(self) -> Self
Loads all available locales into internal cache.
Sourcepub fn debug(self, enable: bool) -> Self
pub fn debug(self, enable: bool) -> Self
Enables debug mode.
This mostly means that Localizer will prefer fetching locales from disk rather than cache.
pub fn default_locale(self, default_locale: &'static str) -> Self
Sourcepub fn localize<'w>(&mut self, tag: &'w str) -> Result<&Locale, LocaleError>where
'w: 'this,
pub fn localize<'w>(&mut self, tag: &'w str) -> Result<&Locale, LocaleError>where
'w: 'this,
§Normal mode
Looks up cache for tag. If not found fetches locale from disk and overwrites old value in cache, returns a reference to new locale afterwards. Otherwise returns cached value.
§Debug mode
Looks up available locales on disk for specified tag. If found, overwrites locale in cache with value from disk and returns a reference to it. Otherwise tries to fetch the locale from cache.
Sourcepub fn localize_no_cache<'w>(
&self,
tag: &'w str,
) -> Result<Cow<'_, Locale>, LocaleError>where
'w: 'this,
pub fn localize_no_cache<'w>(
&self,
tag: &'w str,
) -> Result<Cow<'_, Locale>, LocaleError>where
'w: 'this,
Auto Trait Implementations§
impl<'this> Freeze for Localizer<'this>
impl<'this> RefUnwindSafe for Localizer<'this>
impl<'this> Send for Localizer<'this>
impl<'this> Sync for Localizer<'this>
impl<'this> !Unpin for Localizer<'this>
impl<'this> UnwindSafe for Localizer<'this>
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