wikimedia / cldr-plural-rule-parser
Evaluates plural rules specified in the CLDR project notation.
v2.0.0
2021-02-11 20:47 UTC
Requires
- php: >=7.2.9
Requires (Dev)
- mediawiki/mediawiki-codesniffer: 35.0.0
- mediawiki/mediawiki-phan-config: 0.10.6
- mediawiki/minus-x: 1.1.1
- ockcyp/covers-validator: 1.3.3
- php-parallel-lint/php-console-highlighter: 0.5.0
- php-parallel-lint/php-parallel-lint: 1.2.0
- phpunit/phpunit: ^8.5
This package is auto-updated.
Last update: 2024-11-02 00:04:40 UTC
README
CLDRPluralRuleParser is a PHP library for parsing plural rules specified in the CLDR project.
This library does not contain the rules from the CLDR project, you have to get them yourself.
Here is how you use it:
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.