#localization #icu4x #data-provider

i18n_localiser-rizzen-yazston

The i18n_localiser crate of the Internationalisation project

4 releases (2 breaking)

0.9.1 Mar 24, 2024
0.9.0 Mar 21, 2024
0.8.0 Feb 3, 2024
0.7.0 Dec 18, 2023

#78 in Internationalization (i18n)

Download history 2/week @ 2023-12-17 3/week @ 2024-01-28 7/week @ 2024-02-18 34/week @ 2024-02-25 2/week @ 2024-03-03 2/week @ 2024-03-10 103/week @ 2024-03-17 141/week @ 2024-03-24 29/week @ 2024-03-31

275 downloads per month
Used in 2 crates (via i18n-rizzen-yazston)

BSD-3-Clause

450KB
7.5K SLoC

i18n_localiser

Rizzen Yazston

Welcome to the i18n_localiser crate of the Internationalisation (i18n) project.

This crate consists of five modules:

  • command: Contains the command registry,

  • error: Contains the error enums for other modules,

  • formatter [Private]: The actual string formatter of the localiser,

  • localiser: Contains the localiser,

  • tree [Private]: Simple tagged string type.

Features

Available features for i18n_localiser crate:

  • icu_blob: Allow for instances of BlobDataProvider to be used various ICU4X components that supports {BufferProvider}BufferProvider. An alternative provider when the internal data of ICU4X components are insufficient for a particular use case.

  • icu_compiled_data [default]: Allow for the internal data of the various ICU4X components.

  • icu_extended: Use the more detailed ICU information structs, types, and methods.

  • icu_fs: Allow for instances of FsDataProvider to be used various ICU4X components that supports BufferProvider. An alternative provider when the internal data of ICU4X components are insufficient for a particular use case.

  • logging: To provide some logging information.

  • sync: Allow for rust's concurrency capabilities to be used. Use of Arc and Mutex instead Rc and RefCell.

Modules

command: User defined commands registry

This module contains the command registry for user defined functions.

The module also contains two example commands.

formatter: Formatter (Private)

The Formatter is the formatter state created by parsing a pattern string. The Formatter is used to create localised strings for the provided placeholder values.

localiser: The Localiser

A localiser that connects to a localisation string data store, to obtain strings for the specified language using a string identifier, and formatting the string to replace any placeholders within the string with provided values.

The localiser is capable of caching retrieved strings that are prepared for placeholder replacement, thus can be reused without the need to parse the string for placeholders.

The localiser makes use of all the other component crates that make up the i18n project. Ideally one only needs to use the meta crate i18n, as it includes all the crates including this i18n_localiser crate.

tree: Tree (Private)

A custom tree that is used internally of the formatter. The tree is created by parsing the provided string, then used to create the formatter state, that is used for creating the formatted localised string from provided placeholder values.

See pattern strings.asciidoc in docs of i18n_lexer crate for the pattern formatting specification.

Acknowledgement

Stefano Angeleri for advice on various design aspects of implementing the components of the internationalisation project, and also providing the Italian translation of error message strings.

Dependencies

~28MB
~524K SLoC