Hi all,
Last week we met with Axel and Stas and started plotting the plan to put l20n file format in Gaia.
We know we're close, but it's also a major change that requires massive updates to the ecosystem.
L20n file format offers so much more than what we have right now with properties and DTD, that it will require updates to an underlying data models for most consumers of the format like Pootle, Pontoon, compare-locales etc.
============
Right now, we're ready to land the l20n file format parser in gaia[0]. This will enable a subset of l20n format that matches current feature set of .properties.
It means that on one hand, we will start being able to use l20n, on the other, it will be a very, very limited l20n.
The major change that this will introduce is that we will start recognizing multi-variant strings. In other words, instead of:
foo = {[ plural(n) ]}
foo[zero] = Foo
foo[other] = Foo 2
being three different entities (that's how it is treated right now by majority of our toolchain), but instead it will be stored as a single entity with two different variants and an index to select from.
=============
In order for that to work we need to update compare-locales to recognize the concept of multi-variant strings. Because of that, we created a new compare-locales implementation [1] that supports this new data model paradigm.
We're close to land this in
l10n.mozilla.org for Gaia.
=============
We also need Pootle support. I'm working on basic conversion between po and l20n [2], which should work since we only start with the features that .properties already have.
============
Once we have pootle and
l10n.mozilla.org support, we will land [0] and start experimenting with using it in some Gaia apps. Unfortunately, this will not give people exposure to the benefits of the new format, so I expect that people will have the "Why change if there's no benefit?" confusion :(
==== What's next? ====
In order to really benefit from the new format, we will need a few extensions to the subset. For v3, I'd like to get:
1) Support triple-quote strings.
This will make DOM Overlays easier
2) Support Global vs. Variable vs. Identifier (instead of the current IdOrVar)
This will remove the overlap between variable reference and entity reference:
<name "Firefox">
<foo "Hi, my name is {{ name }}">
<div data-l10n-id='foo' data-l10n-args='{"name": "John"}' />
In the current model we don't specify what should happen. In the proper l20n it should be:
<name "Firefox">
<foo "Hi, my name is {{ $name }}, and the app name is {{ name }}">
<div data-l10n-id='foo' data-l10n-args='{"name": "John"}' />
3) Support CallExpression in placeables.
This will enable
<shortTimeFormat "%I:%M %p">
<foo "{{ @icu.formatDateTime($d, shortTimeFormat) }}">
mozL10n.setAttributes(node, 'foo', {d: new Date().getTime()});
instead of the current:
var f = new navigator.mozL10n.DateTimeFormat();
return f.localeFormat(d, _('shortDateFormat'));
removing the need for DateTimeFormat, mozL10n.get and moving date formatting from developer to localizer.
note: I'm ok not supporting propertyexpressions just yet. So "icu.formatDateTime" is a single name here (same as "cldr.plural" or "gaia.formFactor") for now.
4) Support for @gaia.formFactor
In order to remove per-form factor resources and make langpacks work accross device types, I believe we should land it early:
<foo[@gaia.formFactor] {
phone: "Phone name",
tv: "TV name",
}>
5) Default hash value
This will enable forward compatibility:
<foo[@gaia.formFactor] {
phone: "Phone name",
tv: "TV name",
*other: "name"
}>
=======================
Those five changes will require updates to the parser, serializer, resolver and solution for localization tools (Pootle/Pontoon).
compare-locales.js should not require any changes (except of an updated l20n parser).
Let me know what you think!
zb.
[0]
https://bugzilla.mozilla.org/show_bug.cgi?id=1027684
[1]
https://bugzilla.mozilla.org/show_bug.cgi?id=1037052
[2]
https://github.com/zbraniecki/translate/tree/l20n