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 --use-separate-crates \
18//! --format baked --locales @en @es @fr @it @ja @pt @ru @tr @zh @zh-Hans @zh-Hant \
19//! -m ListAndV1 -o src/data
20//! ```
21
22// tidy-alphabetical-start
23#![allow(elided_lifetimes_in_paths)]
24#![allow(internal_features)]
25#![allow(unreachable_pub)] // because this crate is mostly generated code
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
31pub struct BakedDataProvider;
32
33include!("data/mod.rs");
34const _: () = {
35 impl_data_provider!(BakedDataProvider);
36};
37
38pub const fn baked_data_provider() -> BakedDataProvider {
39 BakedDataProvider
40}
41
42pub mod supported_locales {
43 pub const EN: icu_locale::Locale = icu_locale::locale!("en");
44 pub const ES: icu_locale::Locale = icu_locale::locale!("es");
45 pub const FR: icu_locale::Locale = icu_locale::locale!("fr");
46 pub const IT: icu_locale::Locale = icu_locale::locale!("it");
47 pub const JA: icu_locale::Locale = icu_locale::locale!("ja");
48 pub const PT: icu_locale::Locale = icu_locale::locale!("pt");
49 pub const RU: icu_locale::Locale = icu_locale::locale!("ru");
50 pub const TR: icu_locale::Locale = icu_locale::locale!("tr");
51 pub const ZH_HANS: icu_locale::Locale = icu_locale::locale!("zh-Hans");
52 pub const ZH_HANT: icu_locale::Locale = icu_locale::locale!("zh-Hant");
53}