Debian Codegraph @

debian/rust-vendor/fluent-bundle/README.md

raw
1 # Fluent Bundle
2
3 [![crates.io](https://img.shields.io/crates/v/fluent-bundle.svg)](https://crates.io/crates/fluent-bundle)
4 [![docs.rs](https://img.shields.io/docsrs/fluent-bundle)](https://docs.rs/fluent-bundle)
5 [![Build](https://github.com/projectfluent/fluent-rs/actions/workflows/test.yaml/badge.svg)](https://github.com/projectfluent/fluent-rs/actions/workflows/test.yaml)
6 [![Coverage Status](https://coveralls.io/repos/github/projectfluent/fluent-rs/badge.svg?branch=main)](https://coveralls.io/github/projectfluent/fluent-rs?branch=main)
7
8 The `fluent-rs` workspace is a collection of Rust crates implementing [Project Fluent][],
9 a localization system designed to unleash the entire expressive power of natural language translations.
10
11 This crate is a low-level implementation of a collection of localization messages for a single locale.
12
13 [Project Fluent]: https://projectfluent.org
14
15 Usage
16 -----
17
18 ```rust
19 use fluent_bundle::{FluentBundle, FluentResource};
20 use unic_langid::langid;
21
22 fn main() {
23 let ftl_string = "hello-world = Hello, world!".to_owned();
24 let res = FluentResource::try_new(ftl_string)
25 .expect("Could not parse an FTL string.");
26
27 let langid_en = langid!("en");
28 let mut bundle = FluentBundle::new(vec![langid_en]);
29
30 bundle.add_resource(&res)
31 .expect("Failed to add FTL resources to the bundle.");
32
33 let msg = bundle.get_message("hello-world")
34 .expect("Failed to retrieve a message.");
35 let val = msg.value.expect("Message has no value.");
36
37 let mut errors = vec![];
38 let value = bundle.format_pattern(val, None, &mut errors);
39
40 assert_eq!(&value, "Hello, world!");
41 }
42 ```
43
44 Get Involved
45 ------------
46
47 `fluent-rs` is open-source, licensed under both the Apache 2.0 and MIT licenses. We
48 encourage everyone to take a look at our code and we'll listen to your
49 feedback.
50
51
52 Discuss
53 -------
54
55 We'd love to hear your thoughts on Project Fluent! Whether you're a localizer
56 looking for a better way to express yourself in your language, or a developer
57 trying to make your app localizable and multilingual, or a hacker looking for
58 a project to contribute to, please do get in touch on the mailing list and the
59 IRC channel.
60
61 - Discourse: https://discourse.mozilla.org/c/fluent
62 - Matrix channel: <a href="https://chat.mozilla.org/#/room/#fluent:mozilla.org">#fluent:mozilla.org</a>