-
Notifications
You must be signed in to change notification settings - Fork 81
Backport MessageContext parser changes from fluent 0.6.0 #148
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
Conversation
@@ -13,6 +13,7 @@ export default { | |||
], | |||
'plugins': [ | |||
'external-helpers', | |||
'babel-plugin-optimize-starts-with', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to keep the code as close to fluent@0.6.0
as possible. We started using startsWith('-')
in 0.6.0 to tell terms and messages apart. This plugin converts it to charCodeAt(0) == 45
.
"tag1" | ||
] | ||
} | ||
"qux": "Qux\n#tag1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tags are no longer parsed by the runtime parser so this simply becomes a multiline message value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd be good to unsupport tags in the tests, and probably relnotes.
Removing the tags from the ftl sources feels more discoverable of the change actually happening.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cherry picked ca5f604 as the first commit in the PR.
See also: all the changes in the |
da152ec
to
9277844
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dug a bit in to the difference between master and 0.4.x locally, the parser changes look ok to me.
Only nit is that I think we should make the removal of tags on 0.4.x more explicit.
"tag1" | ||
] | ||
} | ||
"qux": "Qux\n#tag1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd be good to unsupport tags in the tests, and probably relnotes.
Removing the tags from the ftl sources feels more discoverable of the change actually happening.
"tag2" | ||
] | ||
}, | ||
"key4": "Value\n\n\n#tag1\n\n\n#tag2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... here, too.
@@ -72,7 +74,8 @@ class RuntimeParser { | |||
const ch = this._source[this._index]; | |||
|
|||
// We don't care about comments or sections at runtime | |||
if (ch === '/') { | |||
if (ch === '/' || | |||
(ch === '#' && [' ', '#'].includes(this._source[this._index + 1]))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may need to skip also if ch === '#' && ch2 === '\n'
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has to be fixed also on master in #149. I'll backport it together with other changes when master becomes 0.6.1.
(cherry picked from commit ca5f604)
In order to make it easier to upgrade to the new syntax, we'll release fluent 0.4.3 which will keep the API compatibility with 0.4.2 and will be able to read Fluent Syntax 0.5 files (just like fluent 0.6.0). These changes make fluent 0.4.x able to read both Syntax 0.4 and Syntax 0.5 files: - Supported Syntax 0.4 features: - `//` comments. - Sections (`[[ Foo ]]`). - Message definitions may omit the `=` after the identifier if they don't have a value. - Supported Syntax 0.5 features: - `#`, `##` and `###` comments. - Identifiers starting with a dash (`-`) are parsed as terms. The only feature of the old Syntax 0.4 which isn't supported anymore are Tags. In practice we didn't see any of the current consumers of `fluent` 0.4.2 take advantage of tags. In Syntax 0.5, [tags were replaced by attribute defined on terms][terms]. [terms]: https://github.com/projectfluent/fluent/blob/master/spec/CHANGELOG.md#050-january-31-2018
9277844
to
b468110
Compare
In order to make it easier to upgrade to the new syntax, we'll release
fluent
0.4.3 which will keep the API compatibility with 0.4.2 and will be able to read Fluent Syntax 0.5 files (just likefluent
0.6.0).These changes make
fluent
0.4.x able to read both Syntax 0.4 and Syntax 0.5 files:Supported Syntax 0.4 features:
//
comments.[[ Foo ]]
).=
after the identifier if they don't have a value.Supported Syntax 0.5 features:
#
,##
and###
comments.-
) are parsed as terms.The only feature of the old Syntax 0.4 which isn't supported anymore are Tags. In practice we didn't see any of the current consumers of
fluent
0.4.2 take advantage of tags. In Syntax 0.5, tags were replaced by attribute defined on terms.