pub struct LocaleContext { /* private fields */ }Expand description
Runtime locale context with scoped overrides.
Implementations§
Source§impl LocaleContext
impl LocaleContext
Sourcepub fn new(locale: impl Into<Locale>) -> Self
pub fn new(locale: impl Into<Locale>) -> Self
Create a new locale context with the provided locale.
Sourcepub fn current_locale(&self) -> Locale
pub fn current_locale(&self) -> Locale
Get the active locale, honoring any scoped override.
Sourcepub fn base_locale(&self) -> Locale
pub fn base_locale(&self) -> Locale
Get the base locale without considering overrides.
Sourcepub fn set_locale(&self, locale: impl Into<Locale>)
pub fn set_locale(&self, locale: impl Into<Locale>)
Set the base locale.
Sourcepub fn subscribe(&self, callback: impl Fn(&Locale) + 'static) -> Subscription
pub fn subscribe(&self, callback: impl Fn(&Locale) + 'static) -> Subscription
Subscribe to base locale changes.
Sourcepub fn push_override(&self, locale: impl Into<Locale>) -> LocaleOverride
pub fn push_override(&self, locale: impl Into<Locale>) -> LocaleOverride
Push a scoped locale override. Dropping the guard restores the prior locale.
Trait Implementations§
Source§impl Clone for LocaleContext
impl Clone for LocaleContext
Source§fn clone(&self) -> LocaleContext
fn clone(&self) -> LocaleContext
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for LocaleContext
impl !RefUnwindSafe for LocaleContext
impl !Send for LocaleContext
impl !Sync for LocaleContext
impl Unpin for LocaleContext
impl UnsafeUnpin for LocaleContext
impl !UnwindSafe for LocaleContext
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