[][src]Struct druid::LocalizedString

pub struct LocalizedString<T> { /* fields omitted */ }

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.

Implementations

impl<T> LocalizedString<T>[src]

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

Create a new LocalizedString with the given key.

pub fn with_placeholder(self, placeholder: impl Into<ArcStr>) -> Self[src]

Add a placeholder value. This will be used if localization fails.

This is intended for use during prototyping.

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

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

pub fn with_arg(
    self,
    key: &'static str,
    f: impl Fn(&T, &Env) -> FluentValue<'static> + 'static
) -> Self
[src]

Add a named argument and a corresponding closure. 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: Debug> Debug for LocalizedString<T>[src]

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

Auto Trait Implementations

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

impl<T, U> RoundInto<U> for T where
    U: RoundFrom<T>, 

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.