jrmajor / pluralrules
Identify plural categories according to CLDR
Fund package maintenance!
jrmajor
Installs: 13 996
Dependents: 1
Suggesters: 0
Security: 0
Stars: 5
Watchers: 1
Forks: 1
Open Issues: 2
Requires
- php: 8.2 - 8.4
- ext-intl: *
Requires (Dev)
- azjezz/psl: ^3.1
- hoa/compiler: ~3.17
- jrmajor/cs: ^0.6.1
- nette/php-generator: ^4.1
- nunomaduro/collision: ^8.5
- php-standard-library/phpstan-extension: ^2.0
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^11.4
- symfony/console: ^7.0
- symfony/var-dumper: ^7.1
- vaimo/composer-patches: ^5.2
This package is auto-updated.
Last update: 2024-12-01 03:48:15 UTC
README
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