Skip to content

Commit

Permalink
Handle state changes mid async formats (projectfluent#228)
Browse files Browse the repository at this point in the history
* Handle state changes mid async formats

* Separate Bundles

* Refactor code

* Move enum to inner

* Fix tests

* Apply reviewers feedback
  • Loading branch information
zbraniecki authored Jul 8, 2021
1 parent f1f0766 commit 0204b9e
Show file tree
Hide file tree
Showing 9 changed files with 531 additions and 631 deletions.
3 changes: 2 additions & 1 deletion fluent-fallback/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ categories = ["localization", "internationalization"]
chunky-vec = "0.1"
fluent-bundle = "0.15.1"
futures = "0.3"
once_cell = "1.7"
async-trait = "0.1"
unic-langid = { version = "0.9" }
once_cell = "1.8"

[dev-dependencies]
fluent-langneg = "0.13"
unic-langid = { version = "0.9", features = ["macros"] }
fluent-resmgr = { path = "../fluent-resmgr" }
tokio = { version = "1.0", features = ["rt-multi-thread", "macros"] }
7 changes: 4 additions & 3 deletions fluent-fallback/examples/simple-fallback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ fn main() {
app_locales,
bundles,
);
let bundles = loc.bundles();

let mut errors = vec![];

Expand All @@ -124,7 +125,7 @@ fn main() {
let mut args = FluentArgs::new();
args.set("input", i);
args.set("value", collatz(i));
let value = loc
let value = bundles
.format_value_sync("response-msg", Some(&args), &mut errors)
.unwrap()
.unwrap();
Expand All @@ -134,15 +135,15 @@ fn main() {
let mut args = FluentArgs::new();
args.set("input", input.as_str());
args.set("reason", err.to_string());
let value = loc
let value = bundles
.format_value_sync("input-parse-error-msg", Some(&args), &mut errors)
.unwrap()
.unwrap();
println!("{}", value);
}
},
None => {
let value = loc
let value = bundles
.format_value_sync("missing-arg-error", None, &mut errors)
.unwrap()
.unwrap();
Expand Down
Loading

0 comments on commit 0204b9e

Please sign in to comment.