[][src]Struct druid::LocalizedString

pub struct LocalizedString<T> {
    pub(crate) key: &'static str,
    placeholder: Option<String<U20>>,
    args: Option<Vec<(&'static str, ArgSource<T>), U2>>,
    resolved: Option<String<U20>>,
}

A string that can be localized based on the current locale.

At its simplest, a LocalizedString is a key that can be resolved against a map of localized strings for a given locale.

Fields

key: &'static strplaceholder: Option<String<U20>>args: Option<Vec<(&'static str, ArgSource<T>), U2>>resolved: Option<String<U20>>

Methods

impl<T> LocalizedString<T>[src]

pub const fn new(key: &'static str) -> Self[src]

Create a new LocalizedString with the given key.

pub fn localized_str(&self) -> &str[src]

Return the localized value for this string, or the placeholder, if the localization is missing, or the key if there is no placeholder.

impl<T: Data> LocalizedString<T>[src]

pub fn with_arg(
    self,
    key: &'static str,
    f: fn(_: &T, _: &Env) -> ArgValue
) -> Self
[src]

Add a named argument and a corresponding ArgClosure. This closure is a function that will return a value for the given key from the current environment and data.

pub fn resolve<'a>(&'a mut self, data: &T, env: &Env) -> bool[src]

Lazily compute the localized value for this string based on the provided environment and data.

Returns true if the current value of the string has changed.

Trait Implementations

impl<T: Clone> Clone for LocalizedString<T>[src]

impl<T> From<LocalizedString<T>> for LabelText<T>[src]

Auto Trait Implementations

impl<T> Send for LocalizedString<T>

impl<T> Sync for LocalizedString<T>

impl<T> Unpin for LocalizedString<T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> RoundFrom<T> for T[src]

impl<T, U> RoundInto<U> for T where
    U: RoundFrom<T>, 
[src]

impl<T> Same<T> for T[src]

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.