8 releases (5 breaking)

✓ Uses Rust 2018 edition

0.6.1 Oct 4, 2019
0.5.3 Oct 4, 2019
0.4.1 Jul 29, 2019

#38 in Internationalization (i18n)

Download history 12/week @ 2019-06-21 8/week @ 2019-06-28 21/week @ 2019-07-05 9/week @ 2019-07-12 22/week @ 2019-07-19 46/week @ 2019-07-26 131/week @ 2019-08-02 96/week @ 2019-08-09 101/week @ 2019-08-16 50/week @ 2019-08-23 72/week @ 2019-08-30 43/week @ 2019-09-06 70/week @ 2019-09-13 88/week @ 2019-09-20 44/week @ 2019-09-27

268 downloads per month
Used in 3 crates (2 directly)

MIT/Apache

180KB
3.5K SLoC

unic-locale Build Status Coverage Status

unic-locale is an API for managing Unicode Locale Identifiers.

The crate provides a way to create a struct from a string, manipulate its fields, canonicalize it, and serialize into a string.

Usage

use unic_locale::{Locale, ExtensionType};

let loc: Locale = "en-US-u-hc-h12".parse()
    .expect("Parsing.failed");

assert_eq!(loc.get_language(), "en");
assert_eq!(loc.get_script(), None);
assert_eq!(loc.get_region(), Some("US"));

loc.extensions.unicode.set_keyword("ca", "buddhist")
    .expect("Setting extension failed.");

assert_eq!(&loc.to_string(), "en-US-u-ca-buddhist-hc-h12");

Macros

unic-locale can be also compiled with features = ["macros"] which enables locale! macro:

use unic_locale::locale;

let loc = locale!("en-US-u-hc-h24");

assert_eq!(&loc.to_string(), "en-US-u-hc-h24")

The macro allows for compile-time parsing and validation of literal locale identifiers.

Status

The crate is providing fundamental blocks, but is very basic.

In particular, the supported extensions list is very limited and the ergonomics of manipulating them should be improved.

Get Involved

unic-locale is open-source, licensed under the Apache License, Version 2.0. We encourage everyone to take a look at our code and we'll listen to your feedback.

Dependencies

~165KB