Crates.io | icu_provider_fs |
lib.rs | icu_provider_fs |
version | 1.5.0 |
source | src |
created_at | 2020-10-15 15:35:28.895037 |
updated_at | 2024-05-28 20:21:37.408654 |
description | ICU4X data provider that reads from structured data files |
homepage | https://icu4x.unicode.org |
repository | https://github.com/unicode-org/icu4x |
max_upload_size | |
id | 300041 |
size | 46,374 |
icu_provider_fs
is one of the ICU4X
components.
It reads ICU4X data files from the filesystem in a given directory.
use icu_provider_fs::FsDataProvider;
let provider = FsDataProvider::try_new("/path/to/data/directory")
.expect_err("Specify a real directory in the line above");
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
ICU4X
data can be stored in different formats. At the moment there are:
#[no_std]
resource formatThe 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
.
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
For more information on development, authorship, contributing etc. please visit ICU4X home page
.