L20n/Examples: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
mNo edit summary
(no more java, new samples in Meet Pete)
Line 1: Line 1:
As L20n is in its very early stages, the current examples are pretty rudimentary and tailored to show the feasibility of particular aspects. They're not all working on the same fileformat either, merely because that makes them easier to implement. Examples will be listed in chronological order, the further you go down, the bigger will be the differences compared to what's supposed to be the end result.
As L20n is in its very early stages, the current examples are pretty rudimentary and tailored to show the feasibility of particular aspects. They're not all working on the same fileformat either, merely because that makes them easier to implement. Examples will be listed in chronological order, the further you go down, the bigger will be the differences compared to what's supposed to be the end result.
Right now, all demos are implemented in js, with varying use of the dojo toolkit, for no particular reason.
== Meet Pete ==
These demos are based on a pretty good grammar for the file formats, but don't support expressions yet, that's why there are no plural demos in this section. [http://sluggy.com/daily.php?date=070126 Meet Pete] is the code name for this version.


=== App-Toolkit demo ===
=== App-Toolkit demo ===
This demo shows how to compose strings from two separate files, and how to make the resulting string look good. A typical example of a string from toolkit using the application name.
This demo shows how to compose strings from two separate files, and how to make the resulting string look good. A typical example of a string from toolkit using the application name.


It's implemented in java, for no reason but that I thought that antlr was a good tool. It's limited in functionality because antlr has some weeknesses, in particular in generating trees for hierarchical grammars. Like, file has entries, entries have key-values, values could be strings, arrays or hashes, strings can have params. It stopped working at the params level, so that is hacked right now. I didn't go into the detail of implementing expressions to be used for macros/functions, so there's no implementation for plurals.
[http://people.mozilla.com/~axel/l20n/js-l20n/sample-01.html app-toolkit demo]
 
Tested on Firefox 2.
 
=== Accesskeys demo ===
This sample shows how to keep things together that belong together. In this case, that happens to be the value and the accesskey attributes for a HTML button. (Sadly, the accesskey doesn't work in fx2, tips?)
 
[http://people.mozilla.com/~axel/l20n/js-l20n/sample-02.html accesskeys demo]
 
=== Language fallback ===
This sample shows how to implement one locale falling back to another. Using en-GB and en-US with en-GB falling back to en-US is merely because I don't speak any interesting languages, but the fallback path is totally programmatic and can be any locale to any other.


[http://people.mozilla.com/~axel/l20n/ app-toolkit demo]
[http://people.mozilla.com/~axel/l20n/js-l20n/sample-03.html fallback demo]


Tested on Firefox 2 with a Java 5 Update 10.
== JavaScript proof of concept ==
This is a JSON-like modification of the fileformat created to heavily use <code>eval</code> to get expressions for free in JavaScript, and thus being able to demo the plurals stuff. This approach can't support the app-toolkit approach, though.


=== Plurals, DOM, Genders ===
=== Plurals, DOM, Genders ===

Revision as of 12:55, 1 February 2007

As L20n is in its very early stages, the current examples are pretty rudimentary and tailored to show the feasibility of particular aspects. They're not all working on the same fileformat either, merely because that makes them easier to implement. Examples will be listed in chronological order, the further you go down, the bigger will be the differences compared to what's supposed to be the end result.

Right now, all demos are implemented in js, with varying use of the dojo toolkit, for no particular reason.

Meet Pete

These demos are based on a pretty good grammar for the file formats, but don't support expressions yet, that's why there are no plural demos in this section. Meet Pete is the code name for this version.

App-Toolkit demo

This demo shows how to compose strings from two separate files, and how to make the resulting string look good. A typical example of a string from toolkit using the application name.

app-toolkit demo

Tested on Firefox 2.

Accesskeys demo

This sample shows how to keep things together that belong together. In this case, that happens to be the value and the accesskey attributes for a HTML button. (Sadly, the accesskey doesn't work in fx2, tips?)

accesskeys demo

Language fallback

This sample shows how to implement one locale falling back to another. Using en-GB and en-US with en-GB falling back to en-US is merely because I don't speak any interesting languages, but the fallback path is totally programmatic and can be any locale to any other.

fallback demo

JavaScript proof of concept

This is a JSON-like modification of the fileformat created to heavily use eval to get expressions for free in JavaScript, and thus being able to demo the plurals stuff. This approach can't support the app-toolkit approach, though.

Plurals, DOM, Genders

This demo is a js-implemented dojo-based piece showing how plurals would work. In addition to that, it demos how one could map localized objects onto a DOM tree, which seems interesting to me.

It's using a hacked up fileformat much closer to json than what I intend to have in the end. The js-eval based approach didn't work for the app-toolkit composition demo, too. It does work for the plural forms nicely, though, that's why it's still there. And it does DOM.

DOM and plurals demo

Tested on Firefox 2. Uses __proto__, so don't expect this to work in IE.

Back to L20n...