]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blob - vendor/wikimedia/cldr-plural-rule-parser/README.md
MediaWiki 1.30.2
[autoinstallsdev/mediawiki.git] / vendor / wikimedia / cldr-plural-rule-parser / README.md
1 CLDRPluralRuleParser
2 =============
3
4 CLDRPluralRuleParser is a PHP library for parsing
5 [http://cldr.unicode.org/index/cldr-spec/plural-rules](plural rules) specified in the
6 [http://cldr.unicode.org/index](CLDR project).
7
8 This library does not contain the rules from the CLDR project, you have to get them yourself.
9
10 Here is how you use it:
11
12 <pre lang="php">
13 use CLDRPluralRuleParser\Evaluator;
14
15 // Example for English
16 $rules = ['i = 1 and v = 0'];
17 $forms = ['syntax error', 'syntax errors'];
18
19 for ( $i = 0; $i < 3; $i++ ) {
20         $index = Evaluator::evaluate( $i, $rules );
21         echo "This code has $i {$forms[$i]}\n";
22 }
23
24 // This code has 0 syntax errors
25 // This code has 1 syntax error
26 // This code has 2 syntax errors
27 </pre>
28
29 License
30 -------
31
32 The project is licensed under the GPL license 2 or later.