pub enum Language {
// some variants omitted
}
Implementations§
source§impl 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. It is
available if compiled with the english_names
feature.
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_name(engl_name: &str) -> Option<Self>
pub fn from_name(engl_name: &str) -> Option<Self>
Get the ISO code by its English name.
This returns the ISO code by the given English name of the language string, as defined in
the ISO 639 standard. It does not include additional comments, e.g. classification of a
macrolanguage, etc. Only available if compiled with the english_names
feature.
Examples
use isolang::Language;
assert_eq!(Language::from_name("Spanish"), Some(Language::Spa));
sourcepub fn match_names<F>(matcher: F) -> impl Iterator<Item = Self>
pub fn match_names<F>(matcher: F) -> impl Iterator<Item = Self>
Get all matching ISO codes by a provided English name pattern.
This returns the matching ISO codes for the provided matcher. The matcher matches all known English language names.
Examples
use isolang::Language;
assert!(Language::match_names(|lang| lang.contains("Engl")).count() > 1);
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());
Trait Implementations§
source§impl FromStr for Language
impl FromStr for Language
§type Err = ParseLanguageError
type Err = ParseLanguageError
source§impl Ord for Language
impl Ord for Language
source§impl PartialEq for Language
impl PartialEq for Language
source§impl PartialOrd for Language
impl PartialOrd for Language
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more