pub enum LocalizedText {
Literal(SharedString),
Key(Locales),
}Expand description
User-facing text that can be either a literal string or a typed locale key.
Component constructors accept this type through impl Into<LocalizedText>,
so callers can pass generated keys directly, e.g.
Button::new(locales::common::ok). The actual translation is resolved at
render time from the current LocalesContext, which keeps runtime
language switching working without hardcoded string keys at call sites.
Variants§
Literal(SharedString)
Literal user-facing text that should not be translated.
Key(Locales)
Typed locale key resolved against the active locale during render.
Implementations§
Source§impl LocalizedText
impl LocalizedText
Sourcepub fn literal(text: impl Into<SharedString>) -> Self
pub fn literal(text: impl Into<SharedString>) -> Self
Creates a literal localized text source.
Sourcepub fn resolve(&self, cx: &impl LocalesContext) -> SharedString
pub fn resolve(&self, cx: &impl LocalesContext) -> SharedString
Resolves this text source against the active locale context.
Sourcepub fn stable_seed(&self) -> &str
pub fn stable_seed(&self) -> &str
Returns a stable seed for element ids, tests, and debug output.
Sourcepub fn is_empty_source(&self) -> bool
pub fn is_empty_source(&self) -> bool
Returns whether this text source is definitely empty before translation.
Trait Implementations§
Source§impl Clone for LocalizedText
impl Clone for LocalizedText
Source§fn clone(&self) -> LocalizedText
fn clone(&self) -> LocalizedText
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LocalizedText
impl Debug for LocalizedText
impl Eq for LocalizedText
Source§impl From<&'static str> for LocalizedText
impl From<&'static str> for LocalizedText
Source§impl<F> From<F> for LocalizedText
impl<F> From<F> for LocalizedText
Source§impl From<Locales> for LocalizedText
impl From<Locales> for LocalizedText
Source§fn from(value: SharedString) -> Self
fn from(value: SharedString) -> Self
Source§impl From<String> for LocalizedText
impl From<String> for LocalizedText
Source§impl Hash for LocalizedText
impl Hash for LocalizedText
Source§impl PartialEq for LocalizedText
impl PartialEq for LocalizedText
Source§fn eq(&self, other: &LocalizedText) -> bool
fn eq(&self, other: &LocalizedText) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for LocalizedText
Auto Trait Implementations§
impl Freeze for LocalizedText
impl RefUnwindSafe for LocalizedText
impl Send for LocalizedText
impl Sync for LocalizedText
impl Unpin for LocalizedText
impl UnsafeUnpin for LocalizedText
impl UnwindSafe for LocalizedText
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more