Skip to content

Commit 88c7bf9

Browse files
fnuttenszbraniecki
authored andcommitted
Minor fixes on simple-app example + extra translation (#124)
* fix(simple-app): complete full path to resources Also fixed wrong message path and typos in README and simple-app.rs * feat(simple-app): french translation
1 parent 2a4b92f commit 88c7bf9

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

fluent-bundle/examples/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
This directory contains a set of examples
22
of how to use Fluent.
33

4-
Start with the `simple.rs` which is a very
4+
Start with the `simple-app.rs` which is a very
55
trivial example of a command line application
66
with localization handled by Fluent.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
missing-arg-error = Erreur : veuillez saisir un nombre en paramètre.
2+
input-parse-error = Erreur : impossible d'interpréter le paramètre `{ $input }`. Raison : { $reason }
3+
response-msg =
4+
{ $value ->
5+
[one] La suite de Syracuse du nombre "{ $input }" comporte une valeur.
6+
*[other] La suite de Syracuse du nombre "{ $input }" comporte { $value } valeurs.
7+
}

fluent-bundle/examples/simple-app.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
//! the application can be made localizable
77
//! via Fluent.
88
//!
9-
//! To try the app launch `cargo run --example simple NUM (LOCALES)`
9+
//! To try the app launch `cargo run --example simple-app NUM (LOCALES)`
1010
//!
1111
//! NUM is a number to be calculated, and LOCALES is an optional
1212
//! parameter with a comma-separated list of locales requested by the user.
1313
//!
1414
//! Example:
1515
//!
16-
//! caron run --example simple 123 de,pl
16+
//! cargo run --example simple-app 123 de,pl
1717
//!
1818
//! If the second argument is omitted, `en-US` locale is used as the
1919
//! default one.
@@ -48,7 +48,7 @@ fn read_file(path: &str) -> Result<String, io::Error> {
4848
fn get_available_locales() -> Result<Vec<String>, io::Error> {
4949
let mut locales = vec![];
5050

51-
let res_dir = fs::read_dir("./examples/resources/")?;
51+
let res_dir = fs::read_dir("./fluent-bundle/examples/resources/")?;
5252
for entry in res_dir {
5353
if let Ok(entry) = entry {
5454
let path = entry.path();
@@ -82,7 +82,7 @@ fn get_app_locales(requested: &[&str]) -> Result<Vec<String>, io::Error> {
8282
return Ok(resolved_locales
8383
.into_iter()
8484
.map(|s| String::from(s))
85-
.collect::<Vec<String>>());
85+
.collect());
8686
}
8787

8888
static L10N_RESOURCES: &[&str] = &["simple.ftl"];
@@ -100,7 +100,7 @@ fn main() {
100100
.get(2)
101101
.map_or(vec!["en-US"], |arg| arg.split(",").collect());
102102

103-
// 4. Negotiate it against the avialable ones
103+
// 4. Negotiate it against the available ones
104104
let locales = get_app_locales(&requested).expect("Failed to retrieve available locales");
105105

106106
// 5. Create a new Fluent FluentBundle using the
@@ -110,7 +110,7 @@ fn main() {
110110
// 6. Load the localization resource
111111
for path in L10N_RESOURCES {
112112
let full_path = format!(
113-
"./examples/resources/{locale}/{path}",
113+
"./fluent-bundle/examples/resources/{locale}/{path}",
114114
locale = locales[0],
115115
path = path
116116
);
@@ -147,7 +147,7 @@ fn main() {
147147
args.insert("reason".to_string(), FluentValue::from(err.to_string()));
148148
let mut errors = vec![];
149149
let msg = bundle
150-
.get_message("input-parse-error-msg")
150+
.get_message("input-parse-error")
151151
.expect("Message doesn't exist.");
152152
let pattern = msg.value.expect("Message has no value.");
153153
let value = bundle.format_pattern(&pattern, Some(&args), &mut errors);

0 commit comments

Comments
 (0)