https://github.com/wikimedia/cldrpluralruleparser
Github mirror - our actual code is hosted with Gerrit (please see https://www.mediawiki.org/wiki/Developer_access for contributing)
https://github.com/wikimedia/cldrpluralruleparser
Last synced: 4 months ago
JSON representation
Github mirror - our actual code is hosted with Gerrit (please see https://www.mediawiki.org/wiki/Developer_access for contributing)
- Host: GitHub
- URL: https://github.com/wikimedia/cldrpluralruleparser
- Owner: wikimedia
- License: gpl-2.0
- Created: 2015-08-22T21:41:14.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2025-01-12T00:03:12.000Z (5 months ago)
- Last Synced: 2025-01-30T13:34:45.368Z (4 months ago)
- Language: PHP
- Homepage: https://www.mediawiki.org/wiki/CLDRPluralRuleParser
- Size: 111 KB
- Stars: 8
- Watchers: 19
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: COPYING
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
CLDRPluralRuleParser
=============CLDRPluralRuleParser is a PHP library for parsing
[plural rules](http://cldr.unicode.org/index/cldr-spec/plural-rules) specified in the
[CLDR project](http://cldr.unicode.org/index).This library does not contain the rules from the CLDR project, you have to get them yourself.
Here is how you use it:
```php
use CLDRPluralRuleParser\Evaluator;// Example for English
$rules = ['i = 1 and v = 0'];
$forms = ['syntax error', 'syntax errors'];for ( $i = 0; $i < 3; $i++ ) {
$index = Evaluator::evaluate( $i, $rules );
echo "This code has $i {$forms[$index]}\n";
}// This code has 0 syntax errors
// This code has 1 syntax error
// This code has 2 syntax errors
```License
-------The project is licensed under the GPL license 2 or later.