pub struct LocaleState { /* private fields */ }Expand description
A language and the locale keys a lookup tries for it.
The global language set by set_lang is one of these (see get_lang),
and servers that render for several users at once can build one per user
(or request) and pass it to t_in!.
Building one resolves the fallback chain once (a few small allocations), so every lookup afterwards just walks a short precomputed slice of keys.
Implementations§
Source§impl LocaleState
impl LocaleState
Sourcepub fn new(id: LanguageIdentifier) -> Self
pub fn new(id: LanguageIdentifier) -> Self
Resolves the fallback chain for id.
Sourcepub fn id(&self) -> &LanguageIdentifier
pub fn id(&self) -> &LanguageIdentifier
The language identifier this state was built from (for the global
language, the one passed to set_lang; en-US by default).
Sourcepub fn key(&self) -> &str
pub fn key(&self) -> &str
The canonical string form of id (e.g. "en-US"), which is
the first key the generated caches are probed with.
Sourcepub fn chain(&self) -> impl ExactSizeIterator<Item = &str>
pub fn chain(&self) -> impl ExactSizeIterator<Item = &str>
The locale keys a lookup tries, most specific first, before the catalog’s fallback locale.
Trait Implementations§
Source§impl Debug for LocaleState
impl Debug for LocaleState
Source§impl From<LanguageIdentifier> for LocaleState
impl From<LanguageIdentifier> for LocaleState
Source§fn from(id: LanguageIdentifier) -> Self
fn from(id: LanguageIdentifier) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for LocaleState
impl RefUnwindSafe for LocaleState
impl Send for LocaleState
impl Sync for LocaleState
impl Unpin for LocaleState
impl UnsafeUnpin for LocaleState
impl UnwindSafe for LocaleState
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