9 releases (2 stable)

1.1.0 Jan 26, 2023
1.0.0 Sep 27, 2022
1.0.0-beta1 Aug 5, 2022
0.6.0 May 10, 2022
0.1.0 Oct 15, 2020

#19 in #cldr

Download history 1459/week @ 2022-10-13 1824/week @ 2022-10-20 1567/week @ 2022-10-27 1773/week @ 2022-11-03 2047/week @ 2022-11-10 1500/week @ 2022-11-17 938/week @ 2022-11-24 1089/week @ 2022-12-01 1275/week @ 2022-12-08 1155/week @ 2022-12-15 416/week @ 2022-12-22 217/week @ 2022-12-29 1123/week @ 2023-01-05 706/week @ 2023-01-12 1445/week @ 2023-01-19 765/week @ 2023-01-26

4,120 downloads per month
Used in 6 crates (2 directly)

Unicode-DFS-2016

245KB
4K SLoC

icu_provider_fs crates.io

icu_fs_data_provider is one of the ICU4X components.

It reads ICU4X data files from the filesystem in a given directory. It can also export data to the filesystem via an iterable data provider (see the export module).

Examples

use icu_provider_fs::FsDataProvider;

let provider = FsDataProvider::try_new("/path/to/data/directory")
    .expect_err("Specify a real directory in the line above");

Directory Structure

The ICU4X data directory has a file named manifest.json at the root, and a nested structure with category (ResourceCategory), subcategory@version, optional variant, and language identifier as the leaf data files. For example, Arabic JSON data for cardinal plurals lives at plurals/cardinal@1/ar.json.

The exact form of the directory structure may change over time. ICU4X uses metadata from manifest.json to dynamically interpret different versions of the directory structure.

├── manifest.json
├── dates
│   └── gregory@1
│       ├── ar-EG.json
│       ├── ar.json
│       ├── be.json
│       ⋮
│       └── und.json
└── plurals
    ├── cardinal@1
    │   ├── ar.json
    │   ├── be.json
    │   ⋮
    │   └── und.json
    └── ordinal@1
        ├── ar.json
        ├── be.json
        ⋮
        └── und.json

Resource Formats

ICU4X data can be stored in different formats. At the moment there are:

  • JSON - Textual format, easy to read
  • Postcard - Binary, small #[no_std] resource format
  • Bincode - Binary, fast resource format

The directory passed to the [FsDataProvider] constructor may contain either of them.

Exporting data

To generate the data required for [FsDataProvider], run the following:

icu4x-datagen --keys all --locales full --format dir

To export postcard format, use

icu4x-datagen --keys all --locales full --format dir --syntax postcard

Notice: In order to use encoded data in production, icu_provider has to be added with deserialize_{bincode_1, json, postcard_1} Cargo feature.

More Information

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

Dependencies

~2.6–9MB
~130K SLoC