6
6
//! the application can be made localizable
7
7
//! via Fluent.
8
8
//!
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)`
10
10
//!
11
11
//! NUM is a number to be calculated, and LOCALES is an optional
12
12
//! parameter with a comma-separated list of locales requested by the user.
13
13
//!
14
14
//! Example:
15
15
//!
16
- //! caron run --example simple 123 de,pl
16
+ //! cargo run --example simple-app 123 de,pl
17
17
//!
18
18
//! If the second argument is omitted, `en-US` locale is used as the
19
19
//! default one.
@@ -48,7 +48,7 @@ fn read_file(path: &str) -> Result<String, io::Error> {
48
48
fn get_available_locales ( ) -> Result < Vec < String > , io:: Error > {
49
49
let mut locales = vec ! [ ] ;
50
50
51
- let res_dir = fs:: read_dir ( "./examples/resources/" ) ?;
51
+ let res_dir = fs:: read_dir ( "./fluent-bundle/ examples/resources/" ) ?;
52
52
for entry in res_dir {
53
53
if let Ok ( entry) = entry {
54
54
let path = entry. path ( ) ;
@@ -82,7 +82,7 @@ fn get_app_locales(requested: &[&str]) -> Result<Vec<String>, io::Error> {
82
82
return Ok ( resolved_locales
83
83
. into_iter ( )
84
84
. map ( |s| String :: from ( s) )
85
- . collect :: < Vec < String > > ( ) ) ;
85
+ . collect ( ) ) ;
86
86
}
87
87
88
88
static L10N_RESOURCES : & [ & str ] = & [ "simple.ftl" ] ;
@@ -100,7 +100,7 @@ fn main() {
100
100
. get ( 2 )
101
101
. map_or ( vec ! [ "en-US" ] , |arg| arg. split ( "," ) . collect ( ) ) ;
102
102
103
- // 4. Negotiate it against the avialable ones
103
+ // 4. Negotiate it against the available ones
104
104
let locales = get_app_locales ( & requested) . expect ( "Failed to retrieve available locales" ) ;
105
105
106
106
// 5. Create a new Fluent FluentBundle using the
@@ -110,7 +110,7 @@ fn main() {
110
110
// 6. Load the localization resource
111
111
for path in L10N_RESOURCES {
112
112
let full_path = format ! (
113
- "./examples/resources/{locale}/{path}" ,
113
+ "./fluent-bundle/ examples/resources/{locale}/{path}" ,
114
114
locale = locales[ 0 ] ,
115
115
path = path
116
116
) ;
@@ -147,7 +147,7 @@ fn main() {
147
147
args. insert ( "reason" . to_string ( ) , FluentValue :: from ( err. to_string ( ) ) ) ;
148
148
let mut errors = vec ! [ ] ;
149
149
let msg = bundle
150
- . get_message ( "input-parse-error-msg " )
150
+ . get_message ( "input-parse-error" )
151
151
. expect ( "Message doesn't exist." ) ;
152
152
let pattern = msg. value . expect ( "Message has no value." ) ;
153
153
let value = bundle. format_pattern ( & pattern, Some ( & args) , & mut errors) ;
0 commit comments