Crate icu_datagen
source · [−]Expand description
icu_datagen
is a library to generate data files that can be used in ICU4X data providers.
Data files can be generated either programmatically (i.e. in build.rs
), or through a
command-line utility.
Examples
build.rs
use icu::locid::langid;
use icu_datagen::*;
use std::fs::File;
use std::path::PathBuf;
fn main() {
icu_datagen::datagen(
Some(&[langid!("de"), langid!("en-AU")]),
&icu_datagen::keys(&["list/and@1"]),
&SourceData::default(),
vec![Out::Blob(Box::new(File::create("data.postcard").unwrap()))],
)
.unwrap();
}
Command line
The command line interface can be installed with the bin
Cargo feature.
$ cargo install icu_datagen --features bin
If you need to export keys for experimental components,
enable the experimental
Cargo feature:
$ cargo install icu_datagen --features bin,experimental
Once the tool is installed, you can invoke it like this:
$ icu4x-datagen \
> --all-keys \
> --locales de en-AU \
> --format blob \
> --out data.postcard
More details can be found by running --help
.
Structs
DataProvider
backed by SourceData
Bag of options for datagen source data.
Enums
Specifies a variant of CLDR JSON
Specifies the collation Han database to use.
The output format.
Functions
List of all supported keys
Runs ICU4X datagen.
Identifies errors that are due to missing CLDR data.
Identifies errors that are due to missing ICU export data.
Parses a compiled binary and returns a list of used DataKey
s used by it.
Parses a file of human-readable key identifiers and returns a
list of DataKey
s.