-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@fluent/syntax: Variant values with []
don't roundtrip through the parser/serializer
#512
Comments
This code here fluent.js/fluent-syntax/src/serializer.ts Lines 146 to 148 in f41d910
doesn't take into account that aka, Easy to fix. @stasm, I'm not sure where to test this, though. Should we go as far as have tests in the spec to ensure those are all parse errors? |
As far as I can tell, the issue is that When I was implementing projectfluent/fluent-rs#184 I noticed that test inputs were constructed so things round-trip exactly, but just thought that was to make testing easier and not because it's required by the spec. EDIT: Never mind. I updated my code to re-parse the serialized text and make sure it's identical to the original, and we run into a parse error. Seems like putting the variant's text element on a new line isn't valid syntax (or at least, as implemented by the Rust parser). |
Usually white-space around syntax elements is not significant, but in this case, newlines are. That's in the grammar snippet I linked to. Generally speaking, handling white-space with proper round-tripping is a pro for tooling applications. It's easier that way to not have different tools battle over how to serialize strings. There are tricks to lessen the impact (compare ASTs when deciding to write messages, for example), but generally, full round-trip is good for tooling. Not that I know of an implementations that does that. |
The following Fluent snippet doesn't round-trip right:
shared-photos = { $userName } { $photoCount -> [one][x]added a new photo { $item -> [bucket] to the bucket *[folder] to the folder } *[other] added { $photoCount } new photos }
The result is
shared-photos = { $userName } { $photoCount -> [one] [x]added a new photo { $item -> [bucket] to the bucket *[folder] to the folder } *[other] added { $photoCount } new photos }
Filing here, but it affects all of
js
,python
, andkotlin
.The text was updated successfully, but these errors were encountered: