rustc_baked_icu_data/lib.rs
1//! This crate contains pre-baked ICU4X data, generated by `icu4x-datagen`. The tool
2//! fetches locale data from CLDR and transforms them into const code in statics that
3//! ICU4X can load, via databake. `lib.rs` in this crate is manually written, but all
4//! other code is generated.
5//!
6//! This crate can be regenerated when there's a new CLDR version, though that is unlikely
7//! to result in changes in most cases (currently this only covers list formatting data, which
8//! is rather stable). It may need to be regenerated when updating ICU4X versions, especially
9//! across major versions, in case it fails to compile after an update.
10//!
11//! It must be regenerated when adding new locales to Rust, or if Rust's usage of ICU4X
12//! grows to need more kinds of data.
13//!
14//! To regenerate the data, run this command:
15//!
16//! ```text
17//! icu4x-datagen -W --pretty --fingerprint --use-separate-crates \
18//! --format mod -l en es fr it ja pt ru tr zh zh-Hans zh-Hant \
19//! -k list/and@1 fallback/likelysubtags@1 fallback/parents@1 fallback/supplement/co@1 \
20//! --cldr-tag latest --icuexport-tag latest -o src/data
21//! ```
22
23// tidy-alphabetical-start
24#![allow(elided_lifetimes_in_paths)]
25#![allow(internal_features)]
26#![doc(rust_logo)]
27#![feature(rustdoc_internals)]
28// #![warn(unreachable_pub)] // don't use because this crate is mostly generated code
29// tidy-alphabetical-end
30
31mod data {
32 include!("data/mod.rs");
33 include!("data/any.rs");
34}
35
36pub use data::BakedDataProvider;
37
38pub const fn baked_data_provider() -> BakedDataProvider {
39 data::BakedDataProvider
40}
41
42pub mod supported_locales {
43 pub const EN: icu_locid::Locale = icu_locid::locale!("en");
44 pub const ES: icu_locid::Locale = icu_locid::locale!("es");
45 pub const FR: icu_locid::Locale = icu_locid::locale!("fr");
46 pub const IT: icu_locid::Locale = icu_locid::locale!("it");
47 pub const JA: icu_locid::Locale = icu_locid::locale!("ja");
48 pub const PT: icu_locid::Locale = icu_locid::locale!("pt");
49 pub const RU: icu_locid::Locale = icu_locid::locale!("ru");
50 pub const TR: icu_locid::Locale = icu_locid::locale!("tr");
51 pub const ZH_HANS: icu_locid::Locale = icu_locid::locale!("zh-Hans");
52 pub const ZH_HANT: icu_locid::Locale = icu_locid::locale!("zh-Hant");
53}