[][src]Struct appstream::MarkupTranslatableString

pub struct MarkupTranslatableString(pub BTreeMap<String, String>);

A wrapper around a translable string that can contains markup.

Example

use appstream::MarkupTranslatableString;
let description = MarkupTranslatableString::with_default("<p>Contrast checks whether the contrast between two colors meet the WCAG requirements.</p>")
                .and_locale("cs", "<p>Kontroluje kontrast mezi dvěma zadanými barvami, jestli vyhovuje požadavkům pravidel pro bezbariérové weby (WCAG).</p>")
                .and_locale("es", "<p>Contraste comprueba la diferencia de contraste entre dos colores que cumplen los requisitos WCAG.</p>");

Implementations

impl MarkupTranslatableString[src]

pub fn with_default(text: &str) -> Self[src]

Create a new MarkupTranslatableString using the default locale.

Arguments

  • text - The string that corresponds to the default locale.

pub fn and_locale(self, locale: &str, text: &str) -> Self[src]

Adds a new translation for a specific locale.

Very useful when constructing a TranslatableString manually.

Arguments

  • locale - The locale to use, use with_default if you want the default locale.
  • text - The corresponding translation.

pub fn add_for_element(&mut self, element: &Element)[src]

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 MarkupTranslatableString.

pub fn add_for_locale(&mut self, locale: Option<&str>, text: &str)[src]

Adds a new translation for a speicifc locale.

Arguments

  • locale - The locale to use, the default locale is used if None is set instead.
  • text - The translation corresponding to the locale.

pub fn get_default(&self) -> Option<&String>[src]

Returns the text corresponding to the default locale C.

pub fn get_for_locale(&self, locale: &str) -> Option<&String>[src]

Retrieve the corresponding text for a specific locale if available.

Arguments

  • locale - The locale to retrieve the text for.

pub fn is_empty(&self) -> bool[src]

Whether self contains any translatable strings.

Trait Implementations

impl Clone for MarkupTranslatableString[src]

impl Debug for MarkupTranslatableString[src]

impl Default for MarkupTranslatableString[src]

impl<'de> Deserialize<'de> for MarkupTranslatableString[src]

impl PartialEq<MarkupTranslatableString> for MarkupTranslatableString[src]

impl Serialize for MarkupTranslatableString[src]

impl StructuralPartialEq for MarkupTranslatableString[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> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

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

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

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.