Wednesday, February 08, 2012

Plural rules OK

#MediaWiki aims to support over 300 languages. Not all languages are equal in the way they express things like a plural. The rule for English is easy: one, many. One apple many apples never mind how many, it will be apples.

Other languages express plurals different. How they are expressed is defined in the CLDR standard. They use a formula and consequently languages that express plural in the same way share the same formula.
<pluralRules locales="hr ru sr uk">
<pluralRules count="one">n mod 10 is 1 and n mod 100 is not 11</pluralRule>
<pluralRules count="few">n mod 10 in 2..4 and n mod 100 not in 12..14</pluralRule>
</pluralRules>
These formulas, when known for a language, will be used in MediaWiki when generating messages including numbers. As we already know the language, we just have to look up how a number fits what rule. Using these formulas helps because it prevents us from having to write separate code for each and every language and, when the rules become known for more languages, they will just fit in.

The challenge is to ensure that the CLDR will support every one of the existing 6000+ languages of which we at present only support a twentieth. 
Thanks,
      GerardM

No comments: