Skip to content

Commit

Permalink
Added coomands feature to 'Message' crate, and updated documentation,…
Browse files Browse the repository at this point in the history
… 'Cargo.toml' files, tests of all crates of the 'i18n' project. Corrected various localisation strings for en-ZA in Sqlite3, tests files and examples using localisation string.
  • Loading branch information
rizzen-yazston committed Jun 28, 2023
1 parent afa0d1c commit 28e2f42
Show file tree
Hide file tree
Showing 60 changed files with 1,444 additions and 722 deletions.
23 changes: 19 additions & 4 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
= Changelog
Rizzen Yazston

== i18n 0.6.0 (2023-03-??)
== i18n 0.6.0 (2023-06-??)

WARNING: This update has API breaking changes for some `i18n` crates.

Expand Down Expand Up @@ -39,14 +39,22 @@ Breaking change is the result of changing how ICU data providers are used and pa

* Updated the `i18n_pattern` crate:

** Updated `Formatter` to use `IcuDataProvider`
** Updated `Formatter` to use `IcuDataProvider`.

** Added `CommandRegistry` and `CommandError` for the command patterns.

** Added command callback function `file_path`.

** Updated `Cargo.toml`, tests, examples and documentation.

* Updated `i18n_lstring` crate:
* Updated `i18n_lstring` crate to merge with `i18n_registry` crate:

** Added `Clone` to `#[Derive()]` to allow cloning.

** Renamed `lib.rs` to 'lstring.rs', and moved to `i18n_registry` crate.

** Removed `i18n_lstring` crate

* Added the `i18n_message` crate:

** Added `Message`, `MessageError`.
Expand All @@ -55,6 +63,14 @@ Breaking change is the result of changing how ICU data providers are used and pa

** Added the `Cargo.toml`, license, and documentation.

* Updated `i18n_registry` crate:

** Renamed crate to `i18n_utility`

** Added `lstring` entries in `lib.rs`

** Updated `Cargo.toml`, tests, examples and documentation.

== i18n 0.5.0 (2023-03-16)

WARNING: This update has many API breaking changes for all existing `i18n` crates.
Expand Down Expand Up @@ -149,7 +165,6 @@ Breaking change is the result of changing the implementation of handling error a

* Removed `i18n_error` crate as it is no longer needed after update of error handling.


== i18n 0.4.0 (2023-02-24)

WARNING: This update has many API breaking changes for all existing `i18n` crates.
Expand Down
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
resolver = "2"
members = [
"crates/icu",
"crates/lstring",
"crates/lexer",
"crates/registry",
"crates/utility",
"crates/provider/core",
"crates/provider/sqlite3",
"crates/pattern",
Expand Down
13 changes: 8 additions & 5 deletions README.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@
Rizzen Yazston
:url-unicode: https://unicode.org/
:icu4x: https://github.com/unicode-org/icu4x
:BCP_47_Language_Tag: https://www.rfc-editor.org/rfc/bcp/bcp47.txt

Welcome to the Internationalisation (I18n) project.

The *Internationalisation* project provides alternative components for the {icu4x}[*ICU4X*] project (maintained by the {url-unicode}[*Unicode Consortium*]), yet still depends on many core components of ICU4X for internal functionality, thus can also be seen as an extension library to ICU4X. The Internationalisation project consists of an alternative messaging system, and adding macro functionality to patterns when formatting strings for locales.
The *Internationalisation* project provides alternative components for the {icu4x}[*ICU4X*] project (maintained by the {url-unicode}[*Unicode Consortium*]), yet still depends on many core components of ICU4X for internal functionality, thus can also be seen as an extension library to ICU4X. The Internationalisation project consists of an alternative messaging system, and adding macro functionality to patterns when formatting strings for locales (language tags).

The repository contains the following crates:

- `i18n`: The convenience meta crate that contains selected available crates,
- `i18n_lstring`: Associating a {BCP_47_Language_Tag}[_BCP 47 Language Tag_] to a `String`,
- `i18n_icu`: Contains ICU4X data provider helper,
- `i18n_lexer`: A simple lexer to tokenise a string,
Expand All @@ -24,9 +23,13 @@ The repository contains the following crates:
- `i18n_provider_sqlite3`: Implementation of `i18n_provider` using Sqlite3 as its data store,
- `i18n_registry`: Language tag registry, that caches language tag strings and their `Locale` objects.
- `i18n_utility`: Contains the Language tag registry, and the LString type (language tagged string).
Note:: All these crates on `crates.io` have the names appended with the suffix `-rizzen-yazston` to distinguish them from internationalisation crates created by other authors.
NOTE: All these crates on `crates.io` have the names appended with the suffix `-rizzen-yazston` to distinguish them from internationalisation crates created by other authors.

== 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.

== Usage

Expand Down
19 changes: 5 additions & 14 deletions crates/i18n/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,18 @@ license = "BSD-3-Clause"
readme = "README.asciidoc"
# false prevents publishing while developing, else string of repository identfier
publish = false

# these keys are used when preparing to publish to 'crates.io'
#documentation = "<url, default is docs.rs>"
#homepage = "<url"
# once public GitHub repository is used
#repository = "<github url>"
#'crates.io' has max 5 keywords, of max 20 characters [A-Za-z0-9_-]
#keywords = ["",...]
#'crates.io' has max 5 categories, selected from `crates.io` list
#categories = ["internationalization"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
repository = "https://github.com/rizzen-yazston/i18n"
keywords = ["internationalization", "localization", "icu4x"]
categories = ["internationalization", "localization", "rust-pattern"]

[dependencies]
i18n_icu-rizzen-yazston = { version = "0.5.0", path = "../icu" }
i18n_lexer-rizzen-yazston = { version = "0.5.0", path = "../lexer" }
i18n_lstring-rizzen-yazston = { version = "0.5.0", path = "../lstring" }
i18n_message-rizzen-yazston = { version = "0.5.0", path = "../message" }
i18n_pattern-rizzen-yazston = { version = "0.5.0", path = "../pattern" }
i18n_provider-rizzen-yazston = { version = "0.5.0", path = "../provider/core" }
i18n_provider_sqlite3-rizzen-yazston = { version = "0.5.0", path = "../provider/sqlite3" }
i18n_registry-rizzen-yazston = { version = "0.5.0", path = "../registry" }
i18n_utility-rizzen-yazston = { version = "0.5.0", path = "../utility" }

[lib]
name = "i18n"
18 changes: 10 additions & 8 deletions crates/i18n/README.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,23 @@ Rizzen Yazston

This convenience meta crate contains selected available crates:

- i18n_icu-rizzen-yazston
- `i18n_icu-rizzen-yazston`: Contains ICU4X data provider helper,
- i18n_lexer-rizzen-yazston
- `i18n_lexer-rizzen-yazston`: A simple lexer to tokenise a string,
- i18n_lstring-rizzen-yazston
- `i18n_message-rizzen-yazston`: The multilingual messaging system,
- i18n_message-rizzen-yazston
- `i18n_pattern-rizzen-yazston`: Similar to the `icu_pattern` crate of ICU4X, though with the added support of macro functionality,
- i18n_pattern-rizzen-yazston
- `i18n_provider-rizzen-yazston`: Trait for providing language strings, and error struct,
- i18n_provider-rizzen-yazston
- `i18n_provider_sqlite3-rizzen-yazston`: Implementation of `i18n_provider` using Sqlite3 as its data store,
- i18n_provider_sqlite3-rizzen-yazston
- `i18n_utility-rizzen-yazston`: Contains the Language tag registry, and the LString type (language tagged string).
- i18n_registry-rizzen-yazston
== 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.

== Usage

Expand Down
22 changes: 12 additions & 10 deletions crates/i18n/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
// This file is part of `i18n-rizzen-yazston` crate. For the terms of use, please see the file
// called LICENSE-BSD-3-Clause at the top level of the `i18n-rizzen-yazston` crate.

//! `i18n` is the main meta-crate of the Internationalisation (`i18n`) project.
//! Welcome to the **i18n** crate of the *Internationalisation* (`i18n`) project.
//!
//! This is the main meta-crate of the project.
//!
//! This convenience meta crate contains selected available crates:
//!
//! * i18n_lexer-rizzen-yazston
//! * `i18n_icu-rizzen-yazston`: Contains ICU4X data provider helper,
//!
//! * i18n_lstring-rizzen-yazston
//! * `i18n_lexer-rizzen-yazston`: A simple lexer to tokenise a string,
//!
//! * i18n_pattern-rizzen-yazston
//! * `i18n_message-rizzen-yazston`: The multilingual messaging system,
//!
//! * i18n_message-rizzen-yazston
//! * `i18n_pattern-rizzen-yazston`: Similar to the `icu_pattern` crate of ICU4X, though with the added support of macro functionality,
//!
//! * i18n_provider-rizzen-yazston
//! * `i18n_provider-rizzen-yazston`: Trait for providing language strings, and error struct,
//!
//! * i18n_provider_sqlite3-rizzen-yazston
//! * `i18n_provider_sqlite3-rizzen-yazston`: Implementation of `i18n_provider` using Sqlite3 as its data store,
//!
//! * i18n_registry-rizzen-yazston
//! * `i18n_utility-rizzen-yazston`: Contains the Language tag registry, and the LString type (language tagged string).
//!
//! # Usage
//!
Expand All @@ -35,10 +37,10 @@
//!
//! See the various component crates for usage examples.

pub use i18n_icu-rizzen-yazston as icu;
pub use i18n_lexer-rizzen-yazston as lexer;
pub use i18n_lstring-rizzen-yazston as lstring;
pub use i18n_message-rizzen-yazston as message;
pub use i18n_pattern-rizzen-yazston as pattern;
pub use i18n_provider-rizzen-yazston as provider;
pub use i18n_provider_sqlite3-rizzen-yazston as provider_sqlite3;
pub use i18n_registry-rizzen-yazston as registry;
pub use i18n_utility-rizzen-yazston as utility;
59 changes: 11 additions & 48 deletions crates/icu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,60 +13,23 @@ license = "BSD-3-Clause"
readme = "README.asciidoc"
# false prevents publishing while developing, else string of repository identfier
publish = false

# these keys are used when preparing to publish to 'crates.io'
#documentation = "<url, default is docs.rs>"
#homepage = "<url"
# once public GitHub repository is used
#repository = "<github url>"
#'crates.io' has max 5 keywords, of max 20 characters [A-Za-z0-9_-]
#keywords = ["",...]
#'crates.io' has max 5 categories, selected from `crates.io` list
#categories = ["internationalization"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
repository = "https://github.com/rizzen-yazston/i18n"
keywords = ["internationalization", "localization", "icu4x"]
categories = ["internationalization", "localization", "rust-pattern"]

[dependencies]

[dependencies.icu_provider]
version = "1.1.0"
# Needed for BufferProvider used in i18n_lexer.
features = [ "serde", "deserialize_bincode_1" ]

[dependencies.icu_properties]
version = "1.1.0"
# Needed for BufferProvider
features = [ "serde" ]

[dependencies.icu_segmenter]
version = "0.8.0"
# Needed for BufferProvider
features = [ "serde" ]

[dependencies.icu_plurals]
version = "1.1.0"
# Needed for BufferProvider
features = [ "serde" ]
icu_provider = "1.1.0"
icu_properties = "1.1.0"
icu_segmenter = "0.8.0"
icu_plurals = "1.1.0"
icu_decimal = "1.1.0"
icu_calendar = "1.1.0"
icu_datetime = "1.1.0"

[dependencies.fixed_decimal]
version = "0.5.2"
# Needed for BufferProvider
# Needed for floating point support.
features = [ "ryu" ]

[dependencies.icu_decimal]
version = "1.1.0"
# Needed for BufferProvider
features = [ "serde" ]

[dependencies.icu_calendar]
version = "1.1.0"
# Needed for BufferProvider
features = [ "serde" ]

[dependencies.icu_datetime]
version = "1.1.0"
# Needed for BufferProvider
features = [ "serde" ]

[lib]
name = "i18n_icu"
36 changes: 25 additions & 11 deletions crates/icu/README.asciidoc
Original file line number Diff line number Diff line change
@@ -1,28 +1,42 @@
= i18n_icu
Rizzen Yazston
:Locale: https://docs.rs/icu/latest/icu/locid/struct.Locale.html
:icu_locid: https://crates.io/crates/icu_locid
:icu: https://crates.io/crates/icu
:ICU4X: https://github.com/unicode-org/icu4x
:Unicode Consortium: https://home.unicode.org/
:LanguageIdentifier: https://docs.rs/icu/latest/icu/locid/struct.LanguageIdentifier.html
:BCP_47_Language_Tag: https://www.rfc-editor.org/rfc/bcp/bcp47.txt
:icu4x: https://github.com/unicode-org/icu4x
:url-unicode: https://home.unicode.org/
:DataProvider: https://docs.rs/icu_provider/1.2.0/icu_provider/trait.DataProvider.html

ICU4X data provider helper.
{icu4x}[*ICU4X*] project (maintained by the {url-unicode}[*Unicode Consortium*]) data provider helper.

The `IcuDataProvider` type contains a member `data_provider` holding the `&DataProvider` as a `DataProviderWrapper` type.
The `IcuDataProvider` type contains a member `data_provider` holding the ICU4X `&{DataProvider}[DataProvider]` as a `DataProviderWrapper` type.

The `IcuDataProvider` type also contains non-locale based data used within the `i18n_lexer` crate.

`IcuDataProvider` type is used within the `Rc` type as `Rc<IcuDataProvider>` to prevent unnecessary duplication.

== 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.

== Cargo.toml

```
[dependencies]
i18n_icu-rizzen-yazston = "0.5.0"
icu_provider = "1.1.0"

# These are required for the DataProvider.
icu_properties = "1.1.0"
icu_segmenter = "0.8.0"
icu_plurals = "1.1.0"
icu_decimal = "1.1.0"
icu_calendar = "1.1.0"
icu_datetime = "1.1.0"

# This is required for the DataProvider.
[dependencies.fixed_decimal]
version = "0.5.2"
# Needed for floating point support.
features = [ "ryu" ]
```

== Examples

See various examples of `i18n_lexer`, `i18n_pattern`, and `i18n_message` crates.
See various examples of the `i18n_lexer`, `i18n_pattern`, and `i18n_message` crates.
4 changes: 1 addition & 3 deletions crates/icu/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ pub enum IcuError {
}

impl Display for IcuError {

/// Simply call the display formatter of embedded error.
fn fmt( &self, formatter: &mut Formatter ) -> Result {
match *self {
match self {
IcuError::Properties( ref error ) => error.fmt( formatter ),
IcuError::Segmenter( ref error ) => error.fmt( formatter ),
}
Expand Down
5 changes: 5 additions & 0 deletions crates/icu/src/icu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ where
/// `DataProviderWrapper` type, which is provided by this crate. Besides storing the `DataProvider`, it also
/// obtains and stores the Pattern_Syntax character set, the Pattern_White_Space character set, and the Grapheme
/// Cluster Segmenter required for the `Lexer` types to function.
/// See `i18n_lexer` crate on usage.
pub fn try_new( data_provider: &'a P ) -> Result<Self, IcuError> {
let syntax = load_pattern_syntax( data_provider )?;
let white_space = load_pattern_white_space( data_provider )?;
Expand All @@ -92,21 +93,25 @@ where

/// Get the `DataProviderWrapper` object that can be used in any ICU function that accepts a `DataProvider` as a
/// parameter, as `data_provider().0`.
/// See `i18n_lexer` crate on usage.
pub fn data_provider( &self ) -> &DataProviderWrapper<P> {
&self.data_provider
}

/// Get the preloaded Pattern_Syntax character set.
/// See `i18n_lexer` crate on usage.
pub fn pattern_syntax( &self ) -> &CodePointSetData {
&self.pattern_syntax
}

/// Get the preloaded Pattern_White_Space character set.
/// See `i18n_lexer` crate on usage.
pub fn pattern_white_space( &self ) -> &CodePointSetData {
&self.pattern_white_space
}

/// Get the Grapheme Cluster Segmenter with preloaded character data set.
/// See `i18n_lexer` crate on usage.
pub fn grapheme_segmenter( &self ) -> &GraphemeClusterSegmenter {
&self.grapheme_segmenter
}
Expand Down
Loading

0 comments on commit 28e2f42

Please sign in to comment.