Crates.io | locale-types |
lib.rs | locale-types |
version | 0.4.0 |
source | src |
created_at | 2019-08-26 16:41:57.860884 |
updated_at | 2019-08-27 16:26:36.809907 |
description | Idiomatic types for locale identifiers. |
homepage | |
repository | https://github.com/johnstonskj/locale-types.git |
max_upload_size | |
id | 159824 |
size | 32,508 |
This crate provides a Locale
enumeration, LocaleIdentifier
trait, and a
LocaleString
structure are provided that may be used to parse and construct
locale identifiers in a standards-conformant manner.
It is used by the locale-codes
and locale-settings
crates.
use locale_types::{LocaleIdentifier, LocaleString};
let locale = LocaleString::new("en".to_string()).unwrap()
.with_territory("US".to_string()).unwrap()
.with_code_set("UTF-8".to_string()).unwrap()
.with_modifier("collation=pinyin;currency=CNY".to_string()).unwrap();
println!("{}", locale);
LocaleIdentifier
to return LocaleError on constructor errors.