8 releases (breaking)

1.0.0-beta1 Aug 5, 2022
0.6.0 May 17, 2022
0.5.0 Jan 31, 2022
0.4.0 Nov 2, 2021
0.0.1 Apr 17, 2020

#98 in Internationalization (i18n)

Download history 162/week @ 2022-04-25 237/week @ 2022-05-02 135/week @ 2022-05-09 879/week @ 2022-05-16 686/week @ 2022-05-23 543/week @ 2022-05-30 1039/week @ 2022-06-06 1451/week @ 2022-06-13 1458/week @ 2022-06-20 2484/week @ 2022-06-27 1830/week @ 2022-07-04 2033/week @ 2022-07-11 2236/week @ 2022-07-18 3826/week @ 2022-07-25 3390/week @ 2022-08-01 2044/week @ 2022-08-08

11,503 downloads per month
Used in icu4x_ecma402


30K SLoC

icu crates.io

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

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

This crate does not bring any unique functionality. Each module is also available as a stand-alone crate, i.e. icu::list as icu_list.

Data Management

Most functionality relies on data which clients have to provide to the APIs.

ICU4X uses the concept of a DataProvider to separate data from logic. Data providers come in many different forms; the following providers are provided by ICU4X in separate crates:

  • BlobDataProvider: uses an in-memory serde-serialized blob. This is the most flexible provider, and data can be updated at runtime.
  • BakedDataProvider: a code-generated provider that contains the data directly in Rust code. This is the most efficient provider as it's serialization-free, and allows for compile-time optimizations.
  • FsDataProvider: uses a file system tree of Serde files. This is mostly useful for development and not recommended in production for performance reasons.
  • icu_provider_adapters: this crate contains APIs to combine providers or provide additional functionality such as locale fallback.

The data that is required by these providers (in BakedDataProvider's case, the provider itself) can be generated and customized using the icu_datagen crate.

The following example uses the icu_testdata crate, which contains prepackaged data providers for a small set of locales.


use icu::datetime::{mock::parse_gregorian_from_str, options::length, TypedDateTimeFormatter};
use icu::locid::locale;

let provider = icu_testdata::get_provider();

let options =
    length::Bag::from_date_time_style(length::Date::Long, length::Time::Medium).into();

let dtf = TypedDateTimeFormatter::try_new_with_buffer_provider(&provider, &locale!("es").into(), options)
    .expect("Failed to create TypedDateTimeFormatter instance.");

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

let formatted_date = dtf.format(&date);
    "12 de septiembre de 2020, 12:35:00"


ICU4X components share a set of common features that control whether core pieces of functionality are compiled. These features are:

  • std: Whether to include std support. Without this feature, icu is #[no_std]-compatible
  • serde: Whether to include serde::Deserialize implementations for data structs, such as SymbolsV1, and serde::{Serialize, Deserialize} implementations for core libary types, such as Locale. These are required with serde-backed providers like [BlobDataProvider][^1].
  • experimental: Whether to enable experimental preview features. Modules enabled with this feature may not be production-ready and could change at any time.

The following features are only available on the individual crates, but not on this meta-crate:

  • datagen: Whether to implement serde::Serialize and functionality that is only required during data generation.
  • bench: Whether to enable exhaustive benchmarks. This can be enabled on individual crates when running cargo bench.

[^1]: FsDataProvider also requires the serde_human feature if JSON is used, as that data is less preprocessed.

More Information

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


~56K SLoC