Open zbraniecki opened 4 years ago
@mihnita @stasm - how does it look to you?
I think it implements (almost) the use case we wanted to implement. It does not show the use of a numeric placeholder, but shows more in other areas (plural, select).
I find the examples really hard to read (just because there is a lot of "duck tape" building the objects, not because it is rust syntax). See below.
I find it a lot easier to just read the ast.rs
Which is where we want to focus anyway :-)
I think it "propagates" some of the existing problems (like the lack of support for combinations of selectors, what is now nesting in the old MF and in Fluent) But we don't want to do a "one big commit that resolves everything" anyway :-)
In general I wanted to stay away from your experiment here, so that what I came up with is independent (if we independently come up with similar structures that is a good sign :-) And we might be able to "merge" things in ways that would solve more of the requests.
So I apologize if I didn't get involved (until I've seen you pinging me directly :-)
I find the building of the message really hard to read. Not a complaint, I have the same problems with my prototyping using protobuffers. My json prototyping is a bit more readable than the proto one. But still not readable enough.
The ast is pretty readable though.
I wonder if using serde to dump the message in a different syntax (json, yaml?) would be more readable. Or maybe even some "macros" that generates the real ast?
For example:
PatternElement::Placeholder(InlineExpression::VariableReference(Identifier(
"userName".into(),
))),
replaced by:
ph("userName")
The whole English message might be:
let _en = Message_Single([
ph("userName"),
text(" published a post in "),
ph("groupName"),
]);
I am not sure what exactly can be done with the rust macros.
Here's an initial proposal based on Option 2 from #6, using
Placeholder
from #4.