17 releases (8 stable)

2.0.0-beta2 Feb 26, 2025
2.0.0-beta1 Nov 23, 2024
1.5.0 May 28, 2024
1.4.0 Nov 17, 2023
0.1.0 Oct 15, 2020

#543 in Internationalization (i18n)

Download history 1644/week @ 2024-12-04 2221/week @ 2024-12-11 1484/week @ 2024-12-18 616/week @ 2024-12-25 1202/week @ 2025-01-01 1146/week @ 2025-01-08 1291/week @ 2025-01-15 1858/week @ 2025-01-22 1901/week @ 2025-01-29 1955/week @ 2025-02-05 1791/week @ 2025-02-12 2377/week @ 2025-02-19 2346/week @ 2025-02-26 2438/week @ 2025-03-05 2212/week @ 2025-03-12 3054/week @ 2025-03-19

10,558 downloads per month
Used in 12 crates (5 directly)

Unicode-3.0

260KB
4K 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".into())
    .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 marker (DataMarkerInfo), 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 --markers all --locales full --format fs

To export postcard format, use

icu4x-datagen --markers all --locales full --format fs --syntax postcard

More Information

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

Dependencies

~1.7–2.6MB
~51K SLoC