Struct appstream::TranslatableString
source · [−]Expand description
A wrapper around a translatable string.
Example
use appstream::TranslatableString;
let name = TranslatableString::with_default("Contrast")
.and_locale("cs", "Kontrast")
.and_locale("cs", "Kontrast");
Tuple Fields
0: BTreeMap<String, String>
Implementations
Create a new TranslatableString
using the default locale.
Arguments
text
- The string that corresponds to the default locale.
Adds a new translation for a specific locale.
Very useful when constructing a TranslatableString
manually.
Arguments
locale
- The locale to use, usewith_default
if you want the default locale.text
- The corresponding translation.
Adds a new string from a xmltree.Element
XML elements containing a lang
attribute are marked as translatable
and can be used to feed the TranslatableString
.
Adds a new translation for a speicifc locale.
Arguments
locale
- The locale to use, the default locale is used ifNone
is set instead.text
- The translation corresponding to the locale.
Returns the text corresponding to the default locale C
.
Retrieve the corresponding text for a specific locale if available.
Arguments
locale
- The locale to retrieve the text for.
Trait Implementations
Returns the “default value” for a type. Read more
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
Auto Trait Implementations
impl RefUnwindSafe for TranslatableString
impl Send for TranslatableString
impl Sync for TranslatableString
impl Unpin for TranslatableString
impl UnwindSafe for TranslatableString
Blanket Implementations
Mutably borrows from an owned value. Read more