#localization #icu4x #data-provider

i18n_localiser-rizzen-yazston

The i18n_localiser crate of the Internationalisation project

7 unstable releases (3 breaking)

0.10.1 Nov 15, 2024
0.10.0 Aug 2, 2024
0.9.2 Jul 23, 2024
0.9.1 Mar 24, 2024
0.7.0 Dec 18, 2023

#64 in Internationalization (i18n)

Download history 12/week @ 2024-08-05 4/week @ 2024-08-12 20/week @ 2024-09-16 15/week @ 2024-09-23 17/week @ 2024-09-30 1/week @ 2024-10-14 118/week @ 2024-11-11 21/week @ 2024-11-18

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

BSD-3-Clause

535KB
10K 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

~29MB
~537K SLoC