[−][src]Struct appstream::TranslatableString
A wrapper around a translatable string.
Example
use appstream::TranslatableString; let name = TranslatableString::with_default("Contrast") .and_locale("cs", "Kontrast") .and_locale("cs", "Kontrast");
Implementations
impl TranslatableString[src]
pub fn with_default(text: &str) -> Self[src]
Create a new TranslatableString 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_defaultif 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 TranslatableString.
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 ifNoneis 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 TranslatableString[src]
fn clone(&self) -> TranslatableString[src]
fn clone_from(&mut self, source: &Self)1.0.0[src]
impl Debug for TranslatableString[src]
impl Default for TranslatableString[src]
fn default() -> TranslatableString[src]
impl<'de> Deserialize<'de> for TranslatableString[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>, [src]
__D: Deserializer<'de>,
impl PartialEq<TranslatableString> for TranslatableString[src]
fn eq(&self, other: &TranslatableString) -> bool[src]
fn ne(&self, other: &TranslatableString) -> bool[src]
impl Serialize for TranslatableString[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer, [src]
__S: Serializer,
impl StructuralPartialEq for TranslatableString[src]
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
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>,