Confirmed users
1,016
edits
(Created page with "== Introduction == == Goals == == Proposed API == In its simplest form, L20n code/format may look like this: <pre style="color:blue"> <newFile "New File"> <close "Close"> </p...") |
No edit summary |
||
| Line 4: | Line 4: | ||
== Proposed API == | == Proposed API == | ||
=== Simple example === | |||
In its simplest form, L20n code/format may look like this: | In its simplest form, L20n code/format may look like this: | ||
| Line 13: | Line 15: | ||
<pre style="color:blue"> | <pre style="color:blue"> | ||
// Get a new context | |||
let ctx = l20n.getContext(); | |||
// add a resource to the context | |||
ctx.addReference("resource://path") | |||
// pool for entities | |||
let msg = ctx.get("newFile") | |||
let msg2 = ctx.get("close") | |||
</pre> | |||
=== Parameters === | |||
L20n accepts two levels of parameter passing: | |||
* per call | |||
* per context | |||
Per call parameter takes precedence. | |||
<pre style="color:blue"> | |||
<luckyNum "Your lucky number is: {{num}}"> | |||
<signedIn "You're signed in as {{login}}"> | |||
</pre> | |||
<pre style="color:blue"> | |||
// Get a new context | |||
let ctx = l20n.getContext(); | |||
// add a resource to the context | |||
ctx.addReference("resource://path") | |||
// add a per-context parameter | |||
ctx.data['login'] = 'Gandalf' | |||
// pool for entities | |||
let msg = ctx.get("luckyNum", {'num': 7}) | |||
let msg2 = ctx.get("signedIn") | |||
</pre> | |||
=== Veriable referencing === | |||
L20n allows for variable referencing from inside of an entity: | |||
<pre style="color:blue"> | |||
<extName "AdBlock"> | |||
<installExt "Install {{extName}}"> | |||
</pre> | |||
<pre style="color:blue"> | |||
// Get a new context | |||
let ctx = l20n.getContext(); | let ctx = l20n.getContext(); | ||
// add a resource to the context | |||
ctx.addReference("resource://path") | ctx.addReference("resource://path") | ||
// pool for entities | |||
let msg2 = ctx.get("installExt") | |||
</pre> | </pre> | ||