Enum isolang::Language

source ·
pub enum Language {
    // some variants omitted
}

Implementations

Create string representation of this Language as a ISO 639-3 code.

This method will return the ISO 639-3 code, which consists of three letters.

Example
use isolang::Language;

assert_eq!(Language::Deu.to_639_3(), "deu");

Create two-letter ISO 639-1 representation of the language.

This will return a two-letter ISO 639-1 code, if it exists and None otherwise. ISO 639-1 codes are only used for the most common languages.

Example
use isolang::Language;

assert!(Language::Gha.to_639_1().is_none());

Get the English name of this language.

This returns the English name of the language, as defined in the ISO 639 standard. It does not include additional comments, e.g. classification of a macrolanguage, etc.

Examples
use isolang::Language;

assert_eq!(Language::Spa.to_name(), "Spanish");
// macro language
assert_eq!(Language::Swa.to_name(), "Swahili");
// individual language
assert_eq!(Language::Swh.to_name(), "Swahili");

Create a Language instance rom a ISO 639-1 code.

This will return a Language instance if the given string is a valid two-letter language code. For invalid inputs, None is returned.

Example
use isolang::Language;

assert!(Language::from_639_1("de").is_some());
assert!(Language::from_639_1("…").is_none());

Create a Language instance rom a ISO 639-3 code.

This will return a Language instance if the given string is a valid three-letter language code. For invalid inputs, None is returned.

Example
use isolang::Language;

assert!(Language::from_639_3("dan").is_some());
assert!(Language::from_639_1("…").is_none());

Parse language from given locale

This parses a language from a given locale string, as used by UNIX-alike and other systems.

Example
use isolang::Language;

fn main() {
    assert!(Language::from_locale("de_DE.UTF-8") == Some(Language::Deu));
}

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Formats the value using the given formatter. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.