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#![allow(unreachable_pub)] // because this crate is mostly generated code
27#![doc(rust_logo)]
28#![feature(rustdoc_internals)]
29// #![warn(unreachable_pub)] // don't use because this crate is mostly generated code
30// tidy-alphabetical-end
31
32mod data {
33    include!("data/mod.rs");
34    include!("data/any.rs");
35}
36
37pub use data::BakedDataProvider;
38
39pub const fn baked_data_provider() -> BakedDataProvider {
40    data::BakedDataProvider
41}
42
43pub mod supported_locales {
44    pub const EN: icu_locid::Locale = icu_locid::locale!("en");
45    pub const ES: icu_locid::Locale = icu_locid::locale!("es");
46    pub const FR: icu_locid::Locale = icu_locid::locale!("fr");
47    pub const IT: icu_locid::Locale = icu_locid::locale!("it");
48    pub const JA: icu_locid::Locale = icu_locid::locale!("ja");
49    pub const PT: icu_locid::Locale = icu_locid::locale!("pt");
50    pub const RU: icu_locid::Locale = icu_locid::locale!("ru");
51    pub const TR: icu_locid::Locale = icu_locid::locale!("tr");
52    pub const ZH_HANS: icu_locid::Locale = icu_locid::locale!("zh-Hans");
53    pub const ZH_HANT: icu_locid::Locale = icu_locid::locale!("zh-Hant");
54}