Crates.io | language-objects |
lib.rs | language-objects |
version | 1.0.2 |
source | src |
created_at | 2022-08-05 15:26:39.831596 |
updated_at | 2022-08-05 17:28:05.750731 |
description | Work with language objects for localization |
homepage | |
repository | https://github.com/matheusdiasdesouzads/language-objects |
max_upload_size | |
id | 639434 |
size | 22,930 |
Work with language tags and basic language associated data.
// 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
}