Confirmed users
1,016
edits
No edit summary |
No edit summary |
||
| Line 162: | Line 162: | ||
L20n allows localizers to customize their entities and add new ones in the scope of their own locale. | L20n allows localizers to customize their entities and add new ones in the scope of their own locale. | ||
The scope of customizations is as follows: | |||
* Locale may have its own entities that are referred from "global" entities | |||
* Locale may have custom entity properties like "gender" on an entity. | |||
Local entities and properties must not be used outside of the context and should not be called from by the API. | |||
en-US: | en-US: | ||
| Line 216: | Line 221: | ||
en-US: | en-US: | ||
<pre style="color:blue"> | <pre style="color:blue"> | ||
<plural(n) n | <plural(n) n==1?'one':'many'> | ||
<drinks(plural(num)) {one: "Cup", many: "Cups"}> | <drinks(plural(num)) {one: "Cup", many: "Cups"}> | ||
| Line 225: | Line 230: | ||
</pre> | </pre> | ||
== Advanced usage == | |||
Below is an example of a macro that may be used by many slavic locales where [http://en.wikipedia.org/wiki/Polish_language#Nouns_and_adjectives the number and type of gender forms is different depending on the plural form]. | |||
en-US: | |||
<pre style="color:blue"> | <pre style="color:blue"> | ||
< | /* plural form - one, few, many */ | ||
<plural(n) n==1?'one':'many'> | |||
<someone(g) { | |||
masculine: "He", | |||
femine: "She", | |||
neuter: "It, | |||
}> | |||
<someoneWalks(plural(num)) { | |||
one: "{{someone(who)}} walks", | |||
many: "They walk" | |||
}> | |||
</pre> | |||
<pre style="color:blue"> | |||
let msg = ctx.get("someoneWalks", {num: 5, who: "masculine"}) # They walk | |||
</pre> | |||
pl: | |||
<pre style="color:blue"> | |||
/* plural form - one, few, many */ | |||
<plural(n) n%10==1&&n%100!=11?'one':n%10>=2&&n%10<=4&&(n%100<10||n%100>=20)?'few':'many'> | |||
/* gender plural form - one or many */ | |||
<gplural(n) n==1?'one':'many'> | |||
/* | |||
* input: | |||
* n - number | |||
* g - gender: | |||
* pmasculine - Personal masculine | |||
* amasculine - Animate masculine | |||
* imasculine - Inanimate masculine | |||
* femine - Femine | |||
* neuter - Neuter | |||
*/ | |||
<gender(n, g) gplural(n)=='one' ? | |||
(g=='pmasculine||g=='amasculine'||g=='imasculine?'masculine':g) : | |||
(g=='pmasculine'?'masculine':'non_masculine')> | |||
<someoneWalks(plural(num), gender(num, who)) { | |||
one: { | |||
'masculine': "On idzie", | |||
'femine': "Ona idzie", | |||
'neuter': "Ono idzie" | |||
}, | |||
many: { | |||
masculine: "Oni idą", | |||
non_masculine: "One idą" | |||
} | |||
}> | |||
</pre> | </pre> | ||
<pre style="color:blue"> | <pre style="color:blue"> | ||
let msg = ctx.get(" | let msg = ctx.get("someoneWalks", {num: 5, "gender}) # Oni idą | ||
</pre> | </pre> | ||