2 unstable releases

0.1.0 Oct 15, 2020
0.0.1 Apr 17, 2020

#96 in Internationalization (i18n)


Used in icu4x_ecma402

Custom license

325KB
5K SLoC

icu crates.io

icu is the main meta-package of the ICU4X project.

It provides a comperhensive selection of Unicode Internationalization Components in their canonical configurations intended to enable software internationalization capabilities.

The package is provided for convenience and users are encouraged to fine-tune components with the features they need.

The package does not bring any unique functionality. Users can achieve the exact same by manually including the dependent components with pre-selected features.

Data Management

Most of Unicode functionality relies on data which has to be provided to the APIs.

ICU4X project uses a concept of DataProvider - a service used to handle data management.

There can be many different heuristics for handling data management and this meta-package does not supply any default DataProvider.

When using ICU4X users are expected to decide which provider they want to use and instrument it to point at the correct location where the data files are stored.

In the following examples an icu_testdata package is used which wraps an FsDataProvider with locally available subset of data.

Examples

use icu::locid::macros::langid;
use icu::datetime::{DateTimeFormat, date::MockDateTime, options::style};

let provider = icu_testdata::get_provider();

let lid = langid!("en");

let options = style::Bag {
    date: Some(style::Date::Long),
    time: Some(style::Time::Medium),
    ..Default::default()
}.into();

let dtf = DateTimeFormat::try_new(lid, &provider, &options)
    .expect("Failed to create DateTimeFormat instance.");

let date: MockDateTime = "2020-09-12T12:35:00".parse()
    .expect("Failed to parse date.");

let formatted_date = dtf.format(&date);
assert_eq!(formatted_date.to_string(), "September 12, 2020 at 12:35:00 PM");

More Information

For more information on development, authorship, contributing etc. please visit ICU4X home page.

Dependencies

~1.2–1.8MB
~40K SLoC