Struct LanguageSet

Source
pub struct LanguageSet { /* private fields */ }
Expand description

A searchable set of language string instances

Implementations§

Source§

impl LanguageSet

Source

pub fn new(fallback_language: &str, languages: &[Language]) -> Self

Create a new language instance

§Arguments
  • fallback_language - Language code for the fallback language
  • languages - Array of language instances to use
Source

pub fn all_languages(&self) -> Vec<Language>

List all supported languages

Source

pub fn fallback_language(&self) -> Option<&Language>

Return the set’s fallback language

Source

pub fn current_language(&self) -> Option<&Language>

Return the set’s current language

Source

pub fn add_language(&mut self, language: Language)

Add a language to the set

§Arguments
  • language - New language
Source

pub fn load_language( &mut self, filename: &str, resources: HashMap<String, Vec<u8>>, ) -> Result<(), String>

Add a language from a JSON file to the set

§Arguments
  • language - New language
Source

pub fn verify(&self) -> HashMap<String, Vec<String>>

Check the completeness of all language packs against the fallback Returns the list of missing strings for each language

Source

pub fn set_fallback_language(&mut self, language: &str) -> bool

Set the fallback language for lookups

§Arguments
  • language - New language
Source

pub fn set_language(&mut self, language: &str) -> bool

Set the current language for lookups

§Arguments
  • language - New language

returns false if the language code is not recognized

Source

pub fn get_from_lang(&self, language: &str, name: &str) -> Option<&str>

Look up a string in a specific language

§Arguments
  • language - Language to search
  • name - String to find
Source

pub fn get(&self, name: &str) -> Option<&str>

Look up a string

§Arguments
  • name - String to find
Source

pub fn utf8_resource(&self, name: &str) -> Option<&str>

Return an embedded resource as a utf8 string

Source

pub fn binary_resource(&self, name: &str) -> Option<&[u8]>

Return an embedded resource as a slice of bytes

Trait Implementations§

Source§

impl Clone for LanguageSet

Source§

fn clone(&self) -> LanguageSet

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'de> Deserialize<'de> for LanguageSet

Source§

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 Index<&str> for LanguageSet

Source§

type Output = str

The returned type after indexing.
Source§

fn index(&self, name: &str) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl Serialize for LanguageSet

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,