#cldr #icu #fs #unicode #localization #provider

icu_provider_fs

ICU4X data provider that reads from structured data files

4 releases (breaking)

0.4.0 Nov 2, 2021
0.3.0 Jul 30, 2021
0.2.0 Apr 29, 2021
0.1.0 Oct 15, 2020

#92 in Internationalization (i18n)

Download history 4/week @ 2021-09-28 90/week @ 2021-10-05 22/week @ 2021-10-12 24/week @ 2021-10-19 25/week @ 2021-10-26 21/week @ 2021-11-02 9/week @ 2021-11-09 5/week @ 2021-11-16 8/week @ 2021-11-23 34/week @ 2021-11-30 39/week @ 2021-12-07 54/week @ 2021-12-14 4/week @ 2021-12-21 34/week @ 2021-12-28 8/week @ 2022-01-04 46/week @ 2022-01-11

111 downloads per month
Used in 3 crates (2 directly)

Custom license

315KB
4.5K 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
  • 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 from the top level:

cargo run             \
  --bin icu4x-datagen \
  --                  \
  --cldr-tag 39.0.0   \
  --out ./icu4x-data  \
  --all-keys          \
  --all-locales

To export bincode format, use

cargo run             \
  --bin icu4x-datagen \
  --                  \
  --cldr-tag 39.0.0   \
  --out ./icu4x-data  \
  --all-keys          \
  --all-locales       \
  -s bincode

Notice: In order to use bincode encoded data in production, icu_provider_fs has to be added with bincode feature.

More Information

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

Dependencies

~1.3–2.2MB
~46K SLoC

むa