-
Notifications
You must be signed in to change notification settings - Fork 45
Restrict variant keys to Numbers and Identifier #127
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
Comments
I checked all translations in |
Absent any comments, I went ahead and opened #157 with the implementation. |
Well, all the comments are in #90 |
#90 is a discussion about relaxing the grammar of variant keys. Regardless of its outcome, there's a value in starting by restricting the grammar. It will allow us to relax it to our liking later on. I propose that we move #90 to after 1.0 and start with a minimal viable and maximally-extensible design right now. |
My concern from #90 is still valid, and unaddressed: Introducing the concept of Also reducing the character set we have for variants, which would lead to grammatical concepts that had to be latinized to be expressed in Fluent. |
As to your second point: we already limit the ability to express these grammatical concepts by not allowing non-Latin characters in names of attributes. Both the value ( I've said it before: my goal is to definitely allow both. That's #90 or #117. In the meantime, I'd like to restrict the grammar so that we don't have our hands tied when we get to relaxing it. |
I don't believe it's an unreasonable ask to limit variant names to ASCII characters, even more so if:
As a side note, partially related: we currently only have 2 cases in l10n-central where localizers added their own variants (it, fr for Firefox Account brand), both are using English for these variant names ("uppercase", "lowercase"). As someone who has to review these changes, I confess it's a big advantage to have them in English, since it lets me understand what's going on. |
Yeah, I'm with Flod here. I'd like to see us handle the |
The greeting =
{ $state ->
[New York] Hi!
*[other] Hello!
} |
Yes, that's correct. |
I think that this change will make fixing #90 harder. If nothing else, it'll require changes to fixtures that will make it very hard to review for correctness. It'll also require untangling the identifier, and it'll require more invasive changes in parser implementations. It will also put baggage on #117 that that ticket shouldn't lift. Identifiers are to exchange information between the program and the localization. We're already conflating that with XML attribute names, which works both because of luck and because we borrowed some XML_Namechar productions. Adding another (VariantName) is just going to make that problem harder to solve. VariantNames do have their own problem space, as they can be external variable values, return values from globals, as well as Term attribute values. I propose to keep a dedicated AST entry for VariantName, even if it's lexically similar to what Identifier might be at some point. I'm happy to remove the multi-word part of, as I agree that's pretty ill-defined right now. Another benefit is that checks in compare-locales and friends could be written in a forwards-compatible manner. |
Thanks, @Pike. I'm not sure I understood all of your comment. Please find my answers and a few clarification questions below.
The changes to tests should not influence the design of the spec. Regardless, can you explain how the review of #90 would be made harder by this change?
Can you explain what you mean by untangling here?
We're far from being lucky. The current Fluent spec doesn't allow localizing many possible XML attribute names. See https://www.w3.org/TR/xml/#attdecls and https://www.w3.org/TR/xml/#sec-starttags
This is what the spec has to say about the
This means that #117 should be considered with higher priority in order to satisfy the fourth design principle of Fluent (with XML and HTML being one of the most widely-adopted UI languages in existence):
External variable values are strings and #90 has a proposal about how to deal it with them in variant keys without making any concessions. Return values from globals are controlled by the implementation or the developer; it's reasonable to expect them to follow the grammar restrictions defined by the grammar. Term attribute values are the only tricky one on the list, but there's little we can do about it other than accept it and use #90 and this issue as remedies. A valid attribute value of
What do you mean by similar here? |
I don't think that we should take attribute names as a driver for identifiers. I'm using untangling in this sense. If we want to fix our use of identifier in one scenario, we'll likely need to fork the grammar production, and use identifier for identifiers, and attribute names for attribute names. Same goes for variant names. |
I now better understand your position, thanks. Mid-term, I think we should allow
The outcome of #90 will impact whether we'll need a separate production for variant names. If it lands, all complex matching of variants can be achieved with the syntax proposed there. Which is why I don't want to over-engineer this issue right now if it doesn't need it. For our current use-cases, ( If this was only about
My only change is to call this node |
I see three paths forward:
I'd like to make a call by tomorrow. |
I don't see the connection between attribute names and variant names. I don't have an opinion on names and values of things that try to do multiple things at once. |
There's a connection by the virtue of not being
Sorry, but this isn't very helpful :( I was hoping my last comment (#127 (comment)) would help us move forward on this. I realize I've included attributes in this issue now, but this is a response to your feedback to keep |
All of the three options lead to |
OK, thanks. I think it makes sense to go with the safest and the most restricted option right now. i.e. using only |
This is related to #90, in which I'd like to relax the grammar of variant keys. I'd like to start by restricting it to just Numbers and Identifiers. We can relax this later and the benefit of restricting it now is to clarify the exact rules of parsing the surrounding whitespace, as in
[____key____]
.The text was updated successfully, but these errors were encountered: