CLDRPluralRuleParser
CLDRPluralRuleParser is a PHP library for parsing plural rules specified in the CLDR project.
Usage
<?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