Le 20/06/12 13:02, Niklas Laxström a écrit :
No, this is not about a wikitext parser. Rather
something much simpler.
Have a look at [1] and you will see rules like:
n in 0..1
n is 2
n mod 10 in 3..4,9 and n mod 100 not in 10..19,70..79,90..99
Long ago when I wanted to compare the plural rules of MediaWiki and
CLDR I wrote a parser for the CLDR rule format. Unfortunately my
implementation uses regular expression and eval, which makes it
unsuitable for production. Now, writing parsers is not my area of
expertise, so can you please point me how to do this properly with
PHP. Bonus points if it is also easily adaptable to JavaScript.
[1]
http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_r…
Have you considered using the `intl` PHP extension? It provides classes
that supports the plural / number formatting from the CLDR. Out of the
box :-)
That is of course going to need a lot of rewriting and rethinking the
translatewiki system, but that would definitely be a huge time saver on
the long term.
--
Antoine "hashar" Musso