Skip to content

Conversation

stasm
Copy link
Contributor

@stasm stasm commented Feb 7, 2018

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.

@@ -13,6 +13,7 @@ export default {
],
'plugins': [
'external-helpers',
'babel-plugin-optimize-starts-with',
Copy link
Contributor Author

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"
Copy link
Contributor Author

@stasm stasm Feb 7, 2018

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

@stasm stasm requested review from zbraniecki and Pike February 7, 2018 13:56
@stasm
Copy link
Contributor Author

stasm commented Feb 7, 2018

See also: all the changes in the fluent@0.4.2...fluent@0.6.0 range.

@stasm stasm force-pushed the 0.4.x-update-parser branch from da152ec to 9277844 Compare February 7, 2018 16:10
Copy link
Contributor

@Pike Pike left a 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"
Copy link
Contributor

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",
Copy link
Contributor

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]))) {
Copy link
Collaborator

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'.

Copy link
Contributor Author

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.

zbraniecki and others added 2 commits February 8, 2018 10:33
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
@stasm stasm force-pushed the 0.4.x-update-parser branch from 9277844 to b468110 Compare February 8, 2018 09:37
@stasm stasm merged commit 1782ee1 into projectfluent:fluent@0.4.x Feb 8, 2018
@stasm stasm deleted the 0.4.x-update-parser branch February 8, 2018 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants