15 releases (8 stable)

new 1.5.0 May 28, 2024
1.4.0 Nov 17, 2023
1.3.2 Oct 3, 2023
1.2.1 Apr 22, 2023
0.1.0 Oct 15, 2020

#339 in Internationalization (i18n)

Download history 2707/week @ 2024-02-08 1280/week @ 2024-02-15 1653/week @ 2024-02-22 2093/week @ 2024-02-29 2515/week @ 2024-03-07 2315/week @ 2024-03-14 1921/week @ 2024-03-21 2670/week @ 2024-03-28 2159/week @ 2024-04-04 2556/week @ 2024-04-11 2241/week @ 2024-04-18 1675/week @ 2024-04-25 1666/week @ 2024-05-02 1815/week @ 2024-05-09 2043/week @ 2024-05-16 1169/week @ 2024-05-23

6,929 downloads per month
Used in 10 crates (4 directly)

Unicode-3.0

280KB
4.5K SLoC

icu_provider_fs crates.io

icu_provider_fs is one of the ICU4X components.

It reads ICU4X data files from the filesystem in a given directory.

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 a data key (DataKey), and locale (DataLocale) as the leaf data files. For example, Arabic JSON data for cardinal plural rules 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.

Notice: In order for ICU4X to be able to deserialize the returned data, the corresponding Cargo feature has to be activated on the icu_provider crate. See AsDeserializingBufferProvider::as_deserializing.

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

More Information

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

Dependencies

~1.8–2.6MB
~52K SLoC