jrmajor/pluralrules
Identify plural categories according to CLDR
Maintainers
Fund package maintenance!
Requires
- php: 8.3 - 8.5
- ext-intl: *
Requires (Dev)
- azjezz/psl: ^4.2
- hoa/compiler: ~3.17
- jrmajor/cs: ^0.7.0
- nette/php-generator: ^4.2
- nunomaduro/collision: ^8.8
- php-standard-library/phpstan-extension: ^2.0
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^12.4
- symfony/console: ^7.4
- symfony/var-dumper: ^7.4
- vaimo/composer-patches: ^5.3
Suggests
None
Provides
None
Conflicts
None
Replaces
None
MIT 77ef49d15dac84edcaf752ed7d02a7014318a4c9
- Jeremiasz Major <jrh.mjr.woop@gmail.com>
i18nlocalelanguagel10nlocalizationinternationalizationpluralcldrplural rulesplural categories
This package is auto-updated.
Last update: 2026-06-04 06:21:59 UTC
README
👁 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
