3 releases (breaking)
0.8.0 | Feb 3, 2024 |
---|---|
0.7.0 | Dec 18, 2023 |
0.6.1 | Jul 6, 2023 |
#397 in Internationalization (i18n)
55 downloads per month
Used in i18n_message-rizzen-yazst…
180KB
2.5K
SLoC
i18n_pattern
Rizzen Yazston
Pattern parser and formatter
The parser handles the parsing of string tokens into an Abstract Syntax Tree (AST), checking the grammar of patterns is valid. The parser only does the syntactic analysis of the supplied Token vector.
The formatter takes the AST that was generated by the parser and constructs a string template for values to be substituted into. The formatter also does the semantic analysis of the grammar. Once a string template has been constructed, it can be used multiple times by simply supplying new placeholder values when executing the format() method. Depending on the placeholder type of the pattern, a suitable selection of the available data types can be used, these include the basic String
, integers, unsigned integers and floats. In addition to these special ICU4X types are supported such as FixedDecimal
, Date
, Time
and DateTime
structs.
See pattern strings.asciidoc
in docs
of pattern
crate for the pattern formatting specification.
Features
Available features for i18n_icu
crate:
-
compiled_data
(Preferred): Enable thecompiled_data
feature oni18n_icu
. Allow for the internal data of the various ICU4X components. -
blob
: Enable theblob
feature oni18n_icu
. Allow for instances ofBlobDataProvider
to be used various ICU4X components that supports {BufferProvider}BufferProvider
. -
fs
: Enable thefs
feature oni18n_icu
. Allow for instances ofFsDataProvider
to be used various ICU4X components that supportsBufferProvider
. -
sync
: Allow for rust's concurrency capabilities to be used. Use ofArc
andMutex
insteadRc
andRefCell
. -
log
: To provide some logging information.
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
~7MB
~121K SLoC