Skip to content
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

Rename traits to attributes and change syntax #6

Closed
stasm opened this issue Jan 4, 2017 · 7 comments
Closed

Rename traits to attributes and change syntax #6

stasm opened this issue Jan 4, 2017 · 7 comments
Milestone

Comments

@stasm
Copy link
Contributor

stasm commented Jan 4, 2017

Goal

Provide easier syntax for multi-valued messages.

Description

While #5 is about multiple facets of the same value, this is about multiple values. This is useful in case of web components or other UI widgets.

Currently we'd write:

key = Value
  [label] Label

This looks similar to a variant of a select-expression but actually defines a trait and "Label" is a separate value, one of two values of the key message. When #1 is fixed this will become even more confusing, because lists of traits will not require defaults, but will use the same syntax as lists of variants.

The proposed solution is to use . (the dot) as a new syntax for defining traits. Also, to better reflect their purpose, we want to rename traits to attributes.

key = Value
key.label = Label

If there is no value it's definition can be omitted:

file-open.label = Open File
file-open.accesskey = O 

This will also require an addition of attribute-expression:

attribute-expression ::= identifier '.' keyword;
file-open.label = Open File
file-open.accesskey = O 
file-open.title = To open an existing file press Ctrl + { file-open.accesskey }.

Discussion

https://groups.google.com/forum/#!topic/mozilla.tools.l10n/dhWfBXHzuZI

@stasm stasm modified the milestone: 0.2 Jan 19, 2017
@Pike
Copy link
Contributor

Pike commented Jan 19, 2017

The repitition of the base ID is tricky for developers changing strings. We had this in our current strings, when developers would change label, and screw up accesskey, etc.

I expect that repitition to be a source of grief in practice, both when writing messages from scratch and getting copy-n-paste wrong, as well as editing strings to update to new content.

In the newsgroup, there's an alternative compressed version,

file-open
  .label     = File Open
  .accesskey = O 

That looks OK to me.

@stasm
Copy link
Contributor Author

stasm commented Jan 20, 2017

The repitition of the base ID is tricky for developers changing strings. We had this in our current strings, when developers would change label, and screw up accesskey, etc.

That's a great point. I did not consider that.

I too like the syntax @Pike suggested in his comment. That said I am a bit concerned about the edge-cases, like messages with just one attribute:

file-open
    .label = Open File…

…or messages or attributes with complex values:

preferences-open
    .label = { PLATFORM() ->
        [windows] Open Settings
       *[other] Open Preferences
    }
    .accesskey = { PLATFORM() ->
        [windows] S
       *[other] P
    }

I find them okay to read but would like to spend some more time thinking about this.

@stasm
Copy link
Contributor Author

stasm commented Jan 20, 2017

Or combinations of message values and attributes:

preferences-help = Click the Gear button in order to change your { PLATFORM() ->
    [windows] settings
   *[other] preferences
}.
    .title = The Gear button can be found in the upper-right corner of the UI.

or:

preferences-help = 
    | Click the Gear button in order to change your { PLATFORM() ->
        [windows] settings
       *[other] preferences
    }.
    .title = The Gear button can be found in the upper-right corner of the UI.

(I have doubts if | was the right choice for multi-line strings precisely because of how it's used in combination with select expressions. That's a topic for another discussion however.)

@zbraniecki
Copy link
Collaborator

like messages with just one attribute:

Can we support both:

fileMenu.accesskey = Foo

and

fileMenu
  .accesskey = Foo

?

@stasm
Copy link
Contributor Author

stasm commented Jan 26, 2017

I think we could, but I'd also prefer to start with only one version. Let's go ahead with

lipsum
    .label = Lorem

for now.

@stasm
Copy link
Contributor Author

stasm commented Jan 27, 2017

@Pike made a point that allowing a condensed syntax of the lipsum.label = Lorem form might lead developers to believe that they can request lipsum.label from the source code. Given that, it's probably better to not allow it at all.

Also, in order to allow an introduction of an attribute-expression which can be used to reference attributes from placeables (foo-help = Press { foo.accesskey }), we will need to forbid dots . as allowed characters in the identifier.

@zbraniecki
Copy link
Collaborator

@Pike made a point that allowing a condensed syntax of the lipsum.label = Lorem form might lead developers to believe that they can request lipsum.label from the source code.

This is not our experience from working with devs on FxOS.

I'm fine with going for the enforced new line, but I don't believe that the concern is warrant given that devs have been doing it with .properties files for a couple years in FxOS without a problem.

stasm added a commit to stasm/fluent that referenced this issue Jan 30, 2017
@stasm stasm closed this as completed in 78ceed8 Jan 31, 2017
stasm added a commit that referenced this issue Jan 31, 2017
Fix #6. New syntax for attributes
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

No branches or pull requests

3 participants