-
Notifications
You must be signed in to change notification settings - Fork 45
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
Remove Sections, introduce group and file comments #70
Conversation
spec/fluent.asdl
Outdated
fun = Function(str name, span? span) | ||
string = StringExpression(str value, span? span) | ||
number = NumberExpression(str value, span? span) | ||
|
||
comment = Comment(str content, span? span) | ||
comment = Comment(int level, str content, span? span) |
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.
Would it better to introduce three node types instead of the level
field? E.g. SingleComment
, DoubleComment
and TripleComment
.
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.
Not sure which way to go. The concern I have is about semantically correct mixed level comments:
# Foo
### Bar
# Baz
## Qux
key = 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.
These would be four independent Comment
entries with levels: 1
, 3
, 1
, and 2
. Or four independent entries: SingleComment
, TripleComment
, SingleComment
, and a DoubleComment
.
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.
Would it better to introduce three node types instead of the level field? E.g.
SingleComment
,DoubleComment
andTripleComment
.
@Pike, do you have an opinion or a recommendation about this?
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 wouldn't call 'em by markup, but by purpose. So, FileComment
, GroupComment
, MessageComment
or just Comment
. Or just leave them with levels.
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 went for Comment
, GroupComment
and FileComment
. They are explicit and clearly communicate the role. They also define the interpretation of each of the comment types right at the level of the syntax which will will improve the portability of FTL files.
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 struggle a bit to understand how this PR changes the relative positioning of comments and how it impacts their role.
Before this PR it's very clear to me that a comment at the very top of the file is "attached" to it and thus is a "File Level Comment". A comment attached to a message is a "Message Level Comment" and so on.
With this changes I feel like we're getting into a world where there may be multiple "File Level Comments" spread around the file and the distinction between a comment attached to a Message and "standalone" is also unclear to me.
What should happen if the comment attached to a Message is a Group Level Comment? Or File Level Comment?
Lastly, I'm wondering how to translate the new group level comments into a visual representation in a GUI like Pontoon.
For example, with the following FTL:
[[ Menu Items ]]
// Here is a set of menu items
// which you can attach to a menu
key1 = Value
key2 = Value 2
I imagined that in the entry list panel in Pontoon a user would only see the title of the section and maybe an outline around the group of messages affected, and then the comment for that section would be displayed by each of the messages in the main pane.
With the new system, I don't see a good way except of some enforced best-practice to make sure that the first line of the group level comment actually is a "title" of such group and the following lines are describing the group.
Is that not a concern for you?
@@ -23,10 +23,9 @@ | |||
|
|||
module Fluent | |||
{ | |||
res = Resource(entry* body, comment? comment, span? span) | |||
res = Resource(entry* body, span? span) |
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.
What is the expected outcome of "file-level" comment being placed in the middle of the file? Say:
key = Message
# Message level comment
key2 = Message 2
### Suddenly, a wild file-level message appears
key3 = Message 3
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.
It appears in the AST a such: a Comment
entry between key2
and key3
.
spec/fluent.asdl
Outdated
fun = Function(str name, span? span) | ||
string = StringExpression(str value, span? span) | ||
number = NumberExpression(str value, span? span) | ||
|
||
comment = Comment(str content, span? span) | ||
comment = Comment(int level, str content, span? span) |
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.
Not sure which way to go. The concern I have is about semantically correct mixed level comments:
# Foo
### Bar
# Baz
## Qux
key = Value
FWIW, this has never been as clear to me. I find it confusing that the the file-level comment is the first inside of the file while the message-level comment is the first outside (and before) the message.
This doesn't change for
Yes, that's now possible, but I expect the linter to warn against this. In most cases we would only care about the first file-level comment.
Only ## Group Level Comment
foo = Foo …parses as two separate entries: a |
With this change I'm betting on the fact the developers don't care about the titles; they care about the comment. For example (source):
i think Pontoon should show the entire Group Comment for each message. |
spec/CHANGELOG.md
Outdated
`Resource` node has been removed. | ||
|
||
- Renamed `Symbol` to `VariantName` in the ASDL. | ||
|
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.
Should this add something about backwards compatiblity? Is this something we do on the fluent side or on the implementations side?
If it's impl, should there be something here that suggests that impls do this?
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.
What do you mean by add something?
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.
Should we document how we expect implementations to deal with the update from syntax 0.4 to 0.5?
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 we should suggest a way forward when we release 0.5. It will be based on the approach we'll take with our implementations.
spec/fluent.ebnf
Outdated
@@ -31,8 +32,7 @@ word ::= (((char - line-break) - inline-space) - [#x5b#x5c#x5d#x | |||
builtin ::= [A-Z] [A-Z_?-]* | |||
number ::= '-'? [0-9]+ ('.' [0-9]+)? | |||
|
|||
variant-key ::= number | variant-symbol | |||
variant-symbol ::= word (_ word)* | |||
variant-key ::= word (_ word)* |
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.
Is this change intentional?
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.
Yes. The word
production already allows all characters that number
did.
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.
Hmm, but having two numbers next to each other separated by a space is not what we want. OK, I'll bring this back.
f54251d
to
52aa384
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.
yay!
guide/comments.md
Outdated
### Localization for Server-side strings of Firefox Screenshots | ||
### Please don't localize Firefox, Firefox Screenshots, or Screenshots | ||
|
||
## Global phrases shared across pages |
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.
## Global phrases
##
## Phrases shared accross pages.
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.
Not sure that's readable in tools like pontoon. I think we should advertise single-line or at least format-flowed comments.
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.
If I understand @zbraniecki's intent correctly, Pontoon could display only the first line of the comment in places where screen space is tight. This would be similar to how Git treats commit messages.
This is a good practice that we should discuss separately. For now, I made all comments in the PR single-line.
spec/fluent.ebnf
Outdated
section ::= '[[' _? word (_ word)* _? ']]' | ||
comment ::= ('# ' (char - NL)* NL)+ | ||
| ('## ' (char - NL)* NL)+ | ||
| ('### ' (char - NL)* NL)+ |
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.
switch to inline-space
instead of ` space char following the sygil
52aa384
to
812a94c
Compare
guide/comments.md
Outdated
### Localization for Server-side strings of Firefox Screenshots | ||
### Please don't localize Firefox, Firefox Screenshots, or Screenshots | ||
|
||
## Global phrases shared across pages |
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.
Not sure that's readable in tools like pontoon. I think we should advertise single-line or at least format-flowed comments.
guide/comments.md
Outdated
files into smaller groups of messages related to each other; they are | ||
group-level comments. Think of them as of headers with a description. | ||
Group-level comments are intended as a hint for localizers and tools about | ||
the layout of the localization resource. |
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.
Can you add docs on how to end a group? Aka, something like
The grouping ends with the next group comment. Use an empty group comment if there's no following group.
Or something not that butchered.
9d86427
to
1e3ff3e
Compare
Fixes #58. Requires #68 and #69 (both of which are included in this PR right now). Please only review the last commit.