So, I'm on a clear "yes" for the general idea here.
All the names drive me back and forth. To some extent, jargon is cargo
cult, and we understand cargo cult so that's good. But then, it's jargon.
I wonder if we can escape by a leading '.' ? 'Cause that can't be part
of a legal entity anyway?
..caller.foo
..global.bar
Which could also be my suggestions for names. Not opinions, just
throwing those out there.
Axel
On 7/18/14 6:49 PM, Staś Małolepszy wrote:
I'd like to suggest a change to the L20n's syntax of referring to
system-provided and developer-provided variables.
Currently, the syntax uses two characters, $ and @, to denote these
references. I've come to believe that the current syntax is cryptic,
non-discoverable and non-googleable. I'd like to change it to
something more explicit or even verbose.
A number of proposed changes are presented below, with code examples.
I'm looking for your input on the proposed syntax and the keyword
names.
Proposed changes
----------------
I think we could benefit from the existing Property Expression
(foo.bar) or Attribute Expression (foo::bar) syntax. We'd need to
introduce two reserved keywords, one for each of the types of external
information:
1. system information, i.e. globals (@os, @hour, @screen). This data
is available to all entities in all contexts and is
platform-dependent.
Proposed keyword: sys, env, system, platform.
2. developer-provided information, i.e. context data. This data is
shared by entities in one context (a group of l10n resources).
Proposed keyword: ctx, app, var, data, context.
Alternatively, we could prefix the keywords with two underscores and
make it illegal for regular Identifiers to start with double
underscores. We'd end up with: __system and __context, for example.
The Variable symbol and the Global Expression symbol would be removed.
Consequently, macros would use regular Identifiers for their local
variables.
Globals examples
----------------
Current syntax, @os global:
<yourOS "Your OS is {{ @os }}.">
Proposed syntax:
<yourOS "Your OS is {{ sys.os }}.">
<yourOS "Your OS is {{ env.os }}.">
<yourOS "Your OS is {{ system.os }}.">
<yourOS "Your OS is {{ platform.os }}.">
<yourOS "Your OS is {{ __system.os }}.">
Current syntax, @screen global:
<formFactor() { @screen.width.px <= 768 ? 'small' : 'wide' }>
Proposed syntax:
<formFactor() { sys.screen.width.px <= 768 ? 'small' : 'wide' }>
<formFactor() { env.screen.width.px <= 768 ? 'small' : 'wide' }>
<formFactor() { system.screen.width.px <= 768 ? 'small' : 'wide' }>
<formFactor() { platform.screen.width.px <= 768 ? 'small' : 'wide' }>
<formFactor() { __system.screen.width.px <= 768 ? 'small' : 'wide' }>
Ctxdata examples
----------------
Current syntax:
<messages "Messages from {{ $firstName }}">
Proposed syntax:
<messages "Messages from {{ ctx.firstName }}">
<messages "Messages from {{ app.firstName }}">
<messages "Messages from {{ var.firstName }}">
<messages "Messages from {{ data.firstName }}">
<messages "Messages from {{ context.firstName }}">
<messages "Messages from {{ __context.firstName }}">
Current syntax:
<notify[plural($numMsgs), $sender.gender] { … }>
Proposed syntax:
<notify[plural(ctx.numMsgs), ctx.sender.gender] { … }>
<notify[plural(app.numMsgs), app.sender.gender] { … }>
<notify[plural(var.numMsgs), var.sender.gender] { … }>
<notify[plural(data.numMsgs), data.sender.gender] { … }>
<notify[plural(context.numMsgs), context.sender.gender] { … }>
<notify[plural(__context.numMsgs), __context.sender.gender] { … }>
Macro examples
--------------
Current syntax:
<plural($n) { $n == 0 ? "zero" :
$n == 1 ? "one" : "many" }>
Proposed syntax:
<plural(n) { n == 0 ? "zero" :
n == 1 ? "one" : "many" }>
Attribute Expressions?
----------------------
Another option is to overload the attr expr syntax:
<yourOS "Your OS is {{ sys::os }}.">
<formFactor() { sys::screen.width.px <= 768 ? 'small' : 'wide' }>
<messages "Messages from {{ ctx::sender.firstName }}">
<notify[plural(ctx.numMsgs), ctx::sender.gender] { … }>
I'm not sure however if this promotes the right semantics of the '::'
syntax.
* * *
What are your thoughts about this change and the specific new syntax
proposals?
My own preference is for property expressions with 'sys' and 'data'
keywords, but I'm open to arguments in favor of other options.
Thanks,
-stas
_______________________________________________
tools-l10n mailing list
[email protected]
https://lists.mozilla.org/listinfo/tools-l10n