#localization #l10n #i18n #intl #internationalization

fluent-bundle

A localization system designed to unleash the entire expressive power of natural language translations

5 releases (3 breaking)

✓ Uses Rust 2018 edition

0.8.0 Oct 4, 2019
0.7.2 Oct 1, 2019
0.7.1 Aug 1, 2019
0.6.0 Mar 26, 2019
0.5.0 Feb 1, 2019

#8 in Internationalization (i18n)

Download history 214/week @ 2019-06-21 272/week @ 2019-06-28 194/week @ 2019-07-05 110/week @ 2019-07-12 163/week @ 2019-07-19 440/week @ 2019-07-26 728/week @ 2019-08-02 609/week @ 2019-08-09 579/week @ 2019-08-16 538/week @ 2019-08-23 720/week @ 2019-08-30 585/week @ 2019-09-06 821/week @ 2019-09-13 778/week @ 2019-09-20 832/week @ 2019-09-27

2,380 downloads per month
Used in 7 crates (3 directly)

Apache-2.0/MIT

86KB
2K 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 Status 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(&[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 the Apache License, Version 2.0. 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.5MB
~33K SLoC