Skip to content

Commit 77c2b38

Browse files
author
Zibi Braniecki
committed
Migrate resolver to use copy-free parser
This is a massive rewrite of the whole crate. It separates out three crates: fluent-syntax becomes a zero-copy AST+parser(+serialized in the future) compabile with Fluent 0.8 fluent-bundle becomes aligned with fluent-bundle in JS fluent becomes a top-level crate with added simple ResourceManager. All of the code is compatible with current stable Rust 2018.
1 parent 3d69f32 commit 77c2b38

File tree

110 files changed

+3867
-1387
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+3867
-1387
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/target/
2+
*/target/
23
**/*.rs.bk
34
Cargo.lock

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
[workspace]
22
members = [
3+
"fluent-syntax",
4+
"fluent-bundle",
5+
"fluent-cli",
36
"fluent",
4-
"fluent-syntax"
57
]
File renamed without changes.

fluent-bundle/Cargo.toml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[package]
2+
name = "fluent-bundle"
3+
description = """
4+
A localization system designed to unleash the entire expressive power of
5+
natural language translations.
6+
"""
7+
version = "0.4.3"
8+
edition = "2018"
9+
authors = [
10+
"Zibi Braniecki <[email protected]>",
11+
"Staś Małolepszy <[email protected]>"
12+
]
13+
homepage = "http://www.projectfluent.org"
14+
license = "Apache-2.0/MIT"
15+
repository = "https://github.com/projectfluent/fluent-rs"
16+
readme = "README.md"
17+
keywords = ["localization", "l10n", "i18n", "intl", "internationalization"]
18+
categories = ["localization", "internationalization"]
19+
20+
[dependencies]
21+
fluent-locale = "^0.4.1"
22+
fluent-syntax = { path = "../fluent-syntax" }
23+
failure = "0.1"
24+
failure_derive = "0.1"
25+
intl_pluralrules = "1.0"

fluent/README.md renamed to fluent-bundle/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ Usage
2222
-----
2323

2424
```rust
25-
use fluent::bundle::FluentBundle;
25+
extern crate fluent;
26+
27+
use fluent_bundle::FluentBundle;
2628

2729
fn main() {
2830
let mut bundle = FluentBundle::new(&["en-US"]);

fluent/benches/lib.rs renamed to fluent-bundle/benches/lib.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
#![feature(test)]
22

3-
extern crate fluent;
4-
extern crate fluent_syntax;
53
extern crate test;
64

7-
use fluent::bundle::FluentBundle;
5+
use fluent_bundle::bundle::FluentBundle;
86
use fluent_syntax::{ast, parser::parse};
97
use std::fs::File;
108
use std::io;
119
use std::io::Read;
1210
use test::Bencher;
1311

1412
fn read_file(path: &str) -> Result<String, io::Error> {
15-
let mut f = try!(File::open(path));
13+
let mut f = File::open(path)?;
1614
let mut s = String::new();
17-
try!(f.read_to_string(&mut s));
15+
f.read_to_string(&mut s)?;
1816
Ok(s)
1917
}
2018

@@ -27,7 +25,9 @@ fn bench_simple_format(b: &mut Bencher) {
2725

2826
for entry in resource.body {
2927
match entry {
30-
ast::Entry::Message(ast::Message { id, .. }) => ids.push(id.name),
28+
ast::ResourceEntry::Entry(ast::Entry::Message(ast::Message { id, .. })) => {
29+
ids.push(id.name)
30+
}
3131
_ => continue,
3232
};
3333
}
@@ -37,7 +37,7 @@ fn bench_simple_format(b: &mut Bencher) {
3737

3838
b.iter(|| {
3939
for id in &ids {
40-
bundle.format(id.as_str(), None);
40+
bundle.format(id, None);
4141
}
4242
});
4343
}
@@ -51,7 +51,9 @@ fn bench_menubar_format(b: &mut Bencher) {
5151

5252
for entry in resource.body {
5353
match entry {
54-
ast::Entry::Message(ast::Message { id, .. }) => ids.push(id.name),
54+
ast::ResourceEntry::Entry(ast::Entry::Message(ast::Message { id, .. })) => {
55+
ids.push(id.name)
56+
}
5557
_ => continue,
5658
};
5759
}
@@ -66,7 +68,7 @@ fn bench_menubar_format(b: &mut Bencher) {
6668
// widgets may only expect attributes and they shouldn't be forced to display a value.
6769
// Here however it doesn't matter because we know for certain that the message for `id`
6870
// exists.
69-
bundle.format_message(id.as_str(), None);
71+
bundle.format_message(id, None);
7072
}
7173
});
7274
}
File renamed without changes.
File renamed without changes.
File renamed without changes.

fluent/examples/external_arguments.rs renamed to fluent-bundle/examples/external_arguments.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
extern crate fluent;
2-
3-
use fluent::bundle::FluentBundle;
4-
use fluent::types::FluentValue;
1+
use fluent_bundle::bundle::FluentBundle;
2+
use fluent_bundle::types::FluentValue;
53
use std::collections::HashMap;
64

75
fn main() {

0 commit comments

Comments
 (0)