pub struct StaticTranslatableString {
pub translations: HashMap<String, String>,
pub lang: String,
}Expand description
A string with translations for multiple languages
Fields§
§translations: HashMap<String, String>§lang: StringImplementations§
Source§impl StaticTranslatableString
impl StaticTranslatableString
Sourcepub fn from_translations(
translations: HashMap<String, String>,
default_lang: Option<String>,
) -> Self
pub fn from_translations( translations: HashMap<String, String>, default_lang: Option<String>, ) -> Self
Create a new translatable string from a map of translations
Sourcepub fn from_string(s: &str) -> Self
pub fn from_string(s: &str) -> Self
Create from a simple string (assumes English)
Sourcepub fn get(&self, lang: &str) -> String
pub fn get(&self, lang: &str) -> String
Get the string for a specific language, falling back to any available
Sourcepub fn to_string_default(&self) -> String
pub fn to_string_default(&self) -> String
Get the string using the default language
Trait Implementations§
Source§impl Clone for StaticTranslatableString
impl Clone for StaticTranslatableString
Source§fn clone(&self) -> StaticTranslatableString
fn clone(&self) -> StaticTranslatableString
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for StaticTranslatableString
impl Debug for StaticTranslatableString
Source§impl Default for StaticTranslatableString
impl Default for StaticTranslatableString
Source§fn default() -> StaticTranslatableString
fn default() -> StaticTranslatableString
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for StaticTranslatableString
impl<'de> Deserialize<'de> for StaticTranslatableString
Source§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
Source§impl Display for StaticTranslatableString
impl Display for StaticTranslatableString
Auto Trait Implementations§
impl Freeze for StaticTranslatableString
impl RefUnwindSafe for StaticTranslatableString
impl Send for StaticTranslatableString
impl Sync for StaticTranslatableString
impl Unpin for StaticTranslatableString
impl UnsafeUnpin for StaticTranslatableString
impl UnwindSafe for StaticTranslatableString
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more