-
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
Introduce private messages. #68
Conversation
| Section(symb name, comment? comment) | ||
| Comment(comment) | ||
| Junk(str content) | ||
attributes (annot* annotations, span? span) | ||
|
||
base_message = Message(pat? value, attr* attributes) | ||
| PrivateMessage(pat value, tag* tags) |
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 makes it a requirement that PrivateMessages
have a non-null value
. Should we enforce this for now or keep it consistent with public Messages
?
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'm ok enforcing it.
spec/fluent.ebnf
Outdated
identifier ::= [a-zA-Z] [a-zA-Z0-9_-]* | ||
public-identifier ::= [a-zA-Z] [a-zA-Z0-9_-]* | ||
private-identifier ::= '-'+ public-identifier | ||
identifier ::= public-identifier | private-identifier | ||
external ::= '$' identifier |
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 you need to change external
to only accept public-identifier
. Or, maybe I'd even change public-identifier
to identifier
, and then create message-identifier ::= identifier | private-identifier
.
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.
Good call, I like this approach better. Thanks.
spec/fluent.ebnf
Outdated
@@ -41,7 +43,9 @@ tag-list ::= NL (__ tag)+ | |||
attribute ::= NL __ '.' identifier 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.
same here.
9670021
to
675aae2
Compare
675aae2
to
4018791
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.
The asdl changes are a bit above my head, mostly because I don't know if there's a difference between a param thingie and an attributes thingie.
I'd really like ensure that we don't expose attributes on private messages, probably already in this patch.
For the general patch queue, the change log might end up being confusing by adding private messages with some properties, and then removing them again in the next patch. Is that a concern?
guide/external.md
Outdated
and are called placeables. | ||
|
||
It's common to used placeables to interpolate an external argument, provided | ||
by the developer, into the string. |
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.
to used
-> to use
, also, I'd put the provided by the developer
to the end, the sentence is really broken up right now.
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's common to use placeables to interpolate an external argument into the string, provided by the developer
doesn't sound right either. I'll go with It's common to use placeables to interpolate external arguments into the translation. External arguments are provided by the developer and may change on runtime.
spec/fluent.ebnf
Outdated
@@ -69,8 +73,8 @@ block-expression ::= select-expression | |||
| variant-list | |||
|
|||
select-expression ::= inline-expression __ '->' __ variant-list | |||
attribute-expression ::= identifier '.' identifier | |||
variant-expression ::= identifier '[' _? variant-key _? ']' | |||
attribute-expression ::= message-identifier '.' identifier |
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 this is just identifier
, the syntax defines that we can't dereference attributes of private messages?
That'd make inline-expression safe, and we could use an unsafe-inline-expression that adds private-indentifier.identifier as selector-expression instead of inline-expression?
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.
Nice, I like this approach. It makes syntax work for us without adding more... syntax.
We could even go further and define selector-expression
which would be different from inline-expression
and block-expression
and could comprise of:
inline-expression ::= quoted-text
| number
| identifier
| external
| variant-expression
| public-attribute-expression
| call-expression
| placeable
block-expression ::= select-expression
| variant-list
selector-expression ::= quoted-text
| number
| identifier
| external
| public-attribute-expression
| private-attribute-expression
| call-expression
Compare it with:
Line 60 in b9552ae
inline-expression ::= quoted-text |
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.
Yeah, agreed, allowing placeable or variant-expression doesn't make much sense in a selector-expression
The relevant excerpt from The Zephyr Abstract Syntax Description Language, p. 5, § 2.6:
|
4018791
to
bf90ef2
Compare
1f4b490
to
7619b5c
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 wonder if we should open a ticket to allow selectors based on translated text. We had numerous requests for that in the past. Or do we only want to allow that in GLOBALS?
guide/private.md
Outdated
Private messages are similar to regular messages but they can only be used as | ||
references in other messages. Their identifiers start with at least one dash | ||
`-` like in the example above: `-brand-name`. The runtime cannot retrieve | ||
private messages directly. They are best used to define glossary terms which |
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.
Just dropping the glossary
here alltogether sounds good enough for me.
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.
Just to make sure I understand this comment, you'd rather see …to define terms which…
?
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.
@@ -40,19 +44,16 @@ module Fluent | |||
| Placeable(expr expression, span? span) | |||
|
|||
-- Expressions | |||
expr = InlineExpression(inline_expr) | |||
| BlockExpression(block_expr) | |||
inline_expr = StringExpression(string) |
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.
inline_expr
is still used in line 70?
arg = Expression(inline_expr)
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.
Thanks.
spec/fluent.ebnf
Outdated
selector-expression ::= quoted-text | ||
| number | ||
| external-identifier | ||
| public-identifier |
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 should be private-identifier instead of public-identifier, as tags are only on private messages, and I guess the intent is to not select based on translation 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.
Good catch and yes, that's the intent. At least for now.
Fix projectfluent#62. Private messages are similar to regular messages but they can only be used as references in other messages. Their identifiers start with at least one dash `-`, e.g. `-brand-name`. The runtime cannot retrieve private messages directly. They are best used to define glossary terms which can be used consistently across the localization of the entire product. Private messages can store some grammatical information about themselves in tags. Private messages are not allowed to have attributes.
The new `selector-expression` EBNF symbol restricts which expressions can be selectors. The following expressions are now illegal as selectors: - references to public messages, - attribute expressions on public messages, - variant expressions, - select expressions (even when wrapped in a placeable).
7619b5c
to
b690637
Compare
Fix #62.
Private messages are similar to regular messages but they can only be
used as references in other messages. Their identifiers start with at
least one dash
-
, e.g.-brand-name
. The runtime cannot retrieveprivate messages directly. They are best used to define glossary terms
which can be used consistently across the localization of the entire
product.
Private messages can store some grammatical information about themselves
in tags. Private messages are not allowed to have attributes.