-
Notifications
You must be signed in to change notification settings - Fork 97
Home
fluent-rs is a Rust implementation of the Fluent Localization System.
The repository contains a set of crates which are layered on top of each other, aiming to preserve the modularity of the project and allow the customers to select which elements of the system they want to use.
The lowest level crate is fluent-syntax
which offers APIs for operations on the Fluent Syntax AST. At the moment the crate contains the AST and parsing API, and in the future can be extended to provide APIs for other common operations such as comparing nodes, serializing etc.
This crate is the most stable, reaching 1.0 soon, with most of the API ironed out. One area that is open to further consideration is the use of borrowed strings in the AST. This kind of API is very cheap and fast to produce, but in result the crate is not useful for production of the AST or manipulation of one.
One solution may be to turn the AST to use Cow
for all strings.
There's also a helper crate for binaries that can be used to operate on Fluent resources from the command line fluent-cli
. Currently it only exposes the parser, but in the future other tools using fluent-syntax
and fluent-bundle
may be accumulated there.
Low level API is built on top of fluent-syntax
and allows for loading and resolving Fluent messages. It's called fluent-bundle
and provides a I/O-abstract way of initializing FluentResource
objects from Strings, and creating FluentBundle
objects which are collections of FluentResource
references that can be resolved together.
This level is less mature, with some open question around allocation and management of resources and bundles in the application life time. In the current iteration, the model leaves the user how to allocate the resources, which must out-live bundles.
Higher level API is currently being prototype in fluent
crate. This API, named Localization uses a closure passed to the constructor
generateBundleswhich is used to generate and regenerate the iterator over
FluentBundle` objects.
This API allows for dynamic fallbacking over locales, while only loading and paying for the fallbacks when needed. It also retains identity in cases when the bundles and their iterator get to be regenerated (locale selection changes etc.).