23 releases

0.15.3 May 5, 2024
0.15.2 Oct 25, 2021
0.15.1 Apr 26, 2021
0.15.0 Feb 9, 2021
0.6.0 Mar 26, 2019

#377 in Internationalization (i18n)

Download history 31446/week @ 2024-07-01 37775/week @ 2024-07-08 38237/week @ 2024-07-15 37104/week @ 2024-07-22 40297/week @ 2024-07-29 40620/week @ 2024-08-05 40623/week @ 2024-08-12 36198/week @ 2024-08-19 39431/week @ 2024-08-26 38124/week @ 2024-09-02 36180/week @ 2024-09-09 32518/week @ 2024-09-16 35678/week @ 2024-09-23 34949/week @ 2024-09-30 35296/week @ 2024-10-07 34482/week @ 2024-10-14

144,430 downloads per month
Used in 220 crates (21 directly)

Apache-2.0 OR MIT

255KB
3.5K SLoC

Fluent

fluent-rs is a Rust implementation of Project Fluent, a localization framework designed to unleash the entire expressive power of natural language translations.

crates.io Build Coverage Status

Project Fluent keeps simple things simple and makes complex things possible. The syntax used for describing translations is easy to read and understand. At the same time it allows, when necessary, to represent complex concepts from natural languages like gender, plurals, conjugations, and others.

Documentation

Usage

use fluent_bundle::{FluentBundle, FluentResource};
use unic_langid::langid;

fn main() {
    let ftl_string = "hello-world = Hello, world!".to_owned();
    let res = FluentResource::try_new(ftl_string)
        .expect("Could not parse an FTL string.");

    let langid_en = langid!("en");
    let mut bundle = FluentBundle::new(vec![langid_en]);

    bundle.add_resource(&res)
        .expect("Failed to add FTL resources to the bundle.");

    let msg = bundle.get_message("hello-world")
        .expect("Failed to retrieve a message.");
    let val = msg.value.expect("Message has no value.");

    let mut errors = vec![];
    let value = bundle.format_pattern(val, None, &mut errors);

    assert_eq!(&value, "Hello, world!");
}

Status

The implementation is in its early stages and supports only some of the Project Fluent's spec. Consult the list of milestones for more information about release planning and scope.

Local Development

cargo build
cargo test
cargo bench
cargo run --example simple-app

When submitting a PR please use cargo fmt (nightly).

Learn the FTL syntax

FTL is a localization file format used for describing translation resources. FTL stands for Fluent Translation List.

FTL is designed to be simple to read, but at the same time allows to represent complex concepts from natural languages like gender, plurals, conjugations, and others.

hello-user = Hello, { $username }!

Read the Fluent Syntax Guide in order to learn more about the syntax. If you're a tool author you may be interested in the formal EBNF grammar.

Get Involved

fluent-rs is open-source, licensed under both the Apache 2.0 and MIT licenses. We encourage everyone to take a look at our code and we'll listen to your feedback.

Discuss

We'd love to hear your thoughts on Project Fluent! Whether you're a localizer looking for a better way to express yourself in your language, or a developer trying to make your app localizable and multilingual, or a hacker looking for a project to contribute to, please do get in touch on the mailing list and the IRC channel.

Dependencies

~1.2–1.7MB
~37K SLoC