| 1 |
CLDRPluralRuleParser |
| 2 |
============= |
| 3 |
|
| 4 |
CLDRPluralRuleParser is a PHP library for parsing |
| 5 |
[plural rules](http://cldr.unicode.org/index/cldr-spec/plural-rules) specified in the |
| 6 |
[CLDR project](http://cldr.unicode.org/index). |
| 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 |
```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[$index]}\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 |
``` |
| 28 |
|
| 29 |
License |
| 30 |
------- |
| 31 |
|
| 32 |
The project is licensed under the GPL license 2 or later. |