language-objects

Work with language objects for localization


License
ISC

Documentation

language-objects

Work with language tags and basic language associated data.

Usage

// Language and Region are interned reference structures

let lng = Language::parse("en-US").unwrap();
println!("{}", lng.direction());
println!("{}", lng.native_name());
println!("{}", lng.international_name());
println!("{}", lng.region().international_name());

// some regions are parsed as language
assert!(Language::parse("us").unwrap() == Language::parse("en").unwrap());

// omitting region in language tag will supply a default region
assert!(Language::parse("en-US").unwrap() == Language::parse("en").unwrap());

// invalid language
if Language::parse("foozxc").is_none() {
    // procedure
}

let region = Region::parse("us").unwrap();
println!("{}", region.international_name());

// invalid region
if Region::parse("foozxc").is_none() {
    // procedure
}