Enum isolang::Language [] [src]

pub enum Language {
    // some variants omitted
}

Methods

impl Language
[src]

[src]

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");

[src]

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());

[src]

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");

[src]

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());

[src]

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());

[src]

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

impl Clone for Language
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Copy for Language
[src]

impl Hash for Language
[src]

[src]

Feeds this value into the given [Hasher]. Read more

1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl Eq for Language
[src]

impl PartialEq for Language
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

1.0.0
[src]

This method tests for !=.

impl Debug for Language
[src]

[src]

Formats the value using the given formatter.

impl Display for Language
[src]

[src]

Formats the value using the given formatter. Read more