> Vivien <mailto:
2...@vingtetun.org>
> January 26, 2012 3:12 PM
>>> Sent: Tuesday, January 24, 2012 5:51:10 PM
>>> Subject: [b2g] Gaia& Localization
>>>
>>> If you have any opinion about l10n or any concerns please feel free
>>> to
>>> jump in the discussion.
>>>
>> In my last post, I referred to the l10n engine as this: given DOM
>> node |n|,
>>
>> [attributes of |n|] --> l10n-engine --> localized string -->
>> [some text node of |n|]
>>
>> From Vivien's original post, "attributes of |n|" appear to be
>> (l10n-id, l10n-args, l10n-path). I don't understand what these are.
>> Again, a fully worked-out example would help in understanding these.
> From what I've understand of the format so far:
> - l10n-id: is a unique identifier for the string to localize
> - l10n-path: is ... an ... xpath expression (that will not work in
> the web world but that's a leftover from XUL). This can be replace by
> a css selector. I'm not really sure how useful it is. It seems like
> this is done to retrieve some nodes once the content has been
> localized but that's unclear to me.
> - l10n-args: those are some arguments to pass to the translating
> engine to give more information about the context (I can be wrong,
> l10n-guys know much more than me here)
Let me clarify.
There are three node attributes that are in use by L20n on a localizable
node:
- l10n-id: which binds the Node with localizable entity
- l10n-args: which defines local arguments passed by the developer to
the localizer in order to provide localization context (user name, some
numbers, gender etc.)
- l10n-attrs: which defines the list of attributes that can be
localized. By default we will have a set of attributes like title, value
or placeholder that will be whitelisted, but attributes like style, href
or src will not be unless they will be added to this attribute
We also have a separate concept, called DOM Fragment, which may be
localized as well. In case a Node with l10n-id contains a subtree of
nodes, they may be localized together. In such case the HTML code
contains only the DOM structure of the DOM Fragment with attributes that
are not localizable (styles, classes, urls etc.) and node values are DOM
Fragments that will be matched to the HTML DOM Fragment structure.
In such case, we want to allow localizers to reorder nodes within the
DOM Fragment which is a common request from the localizers. If all nodes
within the DOM Fragment have ID's assigned, the localizer will just use
the ID of the node and our algorithm will match the nodes using it, but
a common case is that DOM Fragment contains multiple <strong>, <p> and
<span> elements that do not use ID. In such case localizers may request
the ID to be added, or use another attribute - l10n-path - to point to a
node in the HTML structure, for example saying that the first <span> in
their localization is the third <span> in the original HTML structure.
Since we're all geeks and we speak code, please, review the last three
examples here:
http://zbraniecki.github.com/l20n/ :)
>> Based on previous discussion, I think there are two proposals for how
>> the l10n engine should work
>>
>> 1. Offline, an l10n "compiler" takes LOL as input, emits small/fast
>> compiled-l10n.js to translate strings. Web apps load<[something]
>> src="compiled-l10n.js">. This sets up event listeners etc. for l10n
>> magic.
>>
>> 2. Online, web apps load their LOL directly, let's say<link
>> rel="l10n" href="my-l10n.lol">. If we're using a fallback l10n
>> engine, it reads my-l10n.lol and sets up an engine appropriately. If
>> there's native support, all the magic happens in the rendering engine.
>>
>> Is this accurate?
>
> This is what I have undestand so far.
>
More or less.
I believe that we will want to use l20n.js/l20n-xml.js libraries only
for projects that require cross-engine support. For native code we will
support L20n in Gecko and we will only link to .lol resources which
should be compiled and cached on fly.
Cheers,
g.