[][src]Struct appstream::TranslatableList

pub struct TranslatableList(pub BTreeMap<String, Vec<String>>);

A wrapper around a list of strings that are translatable.

It's mostly used for the list of keywords a component can have

Example

use appstream::TranslatableList;
let keywords = TranslatableList::with_default(vec!["Color", "Contrast", "GNOME", "GTK"])
                        .and_locale("cs", vec!["barva", "kontrast"])
                        .and_locale("da", vec!["Farve", "Kontrast"]);

Implementations

impl TranslatableList[src]

pub fn with_default(words: Vec<&str>) -> Self[src]

Create a new TranslatableList using the default locale.

Arguments

  • words - List of strings to add to the default locale.

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

Adds a list of strings for a specific locale.

Very useful when constructing a TranslatableList manually.

Arguments

  • locale - The locale to use, use with_default if you want the default locale.
  • words - The list of strings to add to this specific locale.

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

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

Adds a new string for a specific locale.

Arguments

  • locale - The locale to use, C is used if None is provided.
  • text - The string to add.

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

Whether self contains any translatable strings.

Trait Implementations

impl Clone for TranslatableList[src]

impl Debug for TranslatableList[src]

impl Default for TranslatableList[src]

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

impl PartialEq<TranslatableList> for TranslatableList[src]

impl Serialize for TranslatableList[src]

impl StructuralPartialEq for TranslatableList[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.