Skip to content

Repository files navigation

jrmajor/pluralrules

Latest Stable Version Required PHP Version

A PHP package for identifying the plural category, according to CLDR, for a given number.

Major\PluralRules\PluralRules::select('en', 1);   // 'one'
Major\PluralRules\PluralRules::select('en', 2);   // 'other'
Major\PluralRules\PluralRules::select('pl', 1);   // 'one'
Major\PluralRules\PluralRules::select('pl', 42);  // 'few'
Major\PluralRules\PluralRules::select('pl', 45);  // 'many'
Major\PluralRules\PluralRules::select('pl', 1.5); // 'other'

You may install it via composer: composer require jrmajor/pluralrules.

Contributing

This package works by compiling CLDR plural rules to PHP closures like these. This is done by gen script (php gen rules and php gen tests). Before running it, you would need to run yarn install to download cldr-core package.

Testing

vendor/bin/phpunit           # Tests
vendor/bin/phpstan analyze   # Static analysis
vendor/bin/php-cs-fixer fix  # Formatting

About

Identify plural categories according to CLDR

Resources

Stars

Watchers

Forks

Releases

Sponsor this project

Used by

Contributors

Languages