[−][src]Struct appstream::MarkupTranslatableString
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, usewith_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 ifNone
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]
fn clone(&self) -> MarkupTranslatableString
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for MarkupTranslatableString
[src]
impl Default for MarkupTranslatableString
[src]
fn default() -> MarkupTranslatableString
[src]
impl<'de> Deserialize<'de> for MarkupTranslatableString
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl PartialEq<MarkupTranslatableString> for MarkupTranslatableString
[src]
fn eq(&self, other: &MarkupTranslatableString) -> bool
[src]
fn ne(&self, other: &MarkupTranslatableString) -> bool
[src]
impl Serialize for MarkupTranslatableString
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl StructuralPartialEq for MarkupTranslatableString
[src]
Auto Trait Implementations
impl RefUnwindSafe for MarkupTranslatableString
impl Send for MarkupTranslatableString
impl Sync for MarkupTranslatableString
impl Unpin for MarkupTranslatableString
impl UnwindSafe for MarkupTranslatableString
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,