pub enum Language {
// some variants omitted
}
Implementations
sourceimpl Language
impl Language
sourcepub fn to_639_3(&self) -> &'static str
pub fn to_639_3(&self) -> &'static str
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");
sourcepub fn to_639_1(&self) -> Option<&'static str>
pub fn to_639_1(&self) -> Option<&'static str>
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());
sourcepub fn to_name(&self) -> &'static str
pub fn to_name(&self) -> &'static str
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");
sourcepub fn from_639_1(code: &str) -> Option<Language>
pub fn from_639_1(code: &str) -> Option<Language>
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());
sourcepub fn from_639_3(code: &str) -> Option<Language>
pub fn from_639_3(code: &str) -> Option<Language>
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());