language-objects

Crates.iolanguage-objects
lib.rslanguage-objects
version1.0.2
sourcesrc
created_at2022-08-05 15:26:39.831596
updated_at2022-08-05 17:28:05.750731
descriptionWork with language objects for localization
homepage
repositoryhttps://github.com/matheusdiasdesouzads/language-objects
max_upload_size
id639434
size22,930
Matheus Dias de Souza (hydroper)

documentation

README

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
}
Commit count: 0

cargo fmt