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

#373 in Internationalization (i18n)

Download history 37516/week @ 2024-08-16 38551/week @ 2024-08-23 38521/week @ 2024-08-30 35880/week @ 2024-09-06 34106/week @ 2024-09-13 35237/week @ 2024-09-20 34619/week @ 2024-09-27 35458/week @ 2024-10-04 35804/week @ 2024-10-11 35471/week @ 2024-10-18 32950/week @ 2024-10-25 36630/week @ 2024-11-01 35041/week @ 2024-11-08 35164/week @ 2024-11-15 36787/week @ 2024-11-22 40815/week @ 2024-11-29

153,274 downloads per month
Used in 235 crates (23 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.1–1.6MB
~36K SLoC