A number to determine the plural count category of a number for use in localization contexts
Warning: The name may change in the near-ish future (mid 2021) to be cohesive with other modules.
If it changes, I will continue to
provide under the current name for at least one year.
# English Arabic Russian
plural-count 0; # other zero many
plural-count 1; # one one one
plural-count 2; # other two few
plural-count 3; # other few few
plural-count 6; # other few many
There are six strings that can be returned by the function: zero, one, two, few, many, and other.
Other is the default and is used for all values in languages that do not have grammatical number.
Note that (as evidenced by the above table), the labels don't always correspond to what one might intuitively think.
Consequently, this is a module generally oriented towards makes of localization frameworks, and less so towards end-users.
plural-count sub currently takes one or two positional arguments:
The number whose count is to be determined.
The count is calculated for a range (
from .. to).
There are two optional named parameters
The language to be used in determining the count. Defaults to
Acceptable values are cardinal and ordinal, defaults to cardinal. Some languages behave differently for these two types of numbers. Ignored for range calculations which always use cardinal
Houses the data for calculating the counts
Determines the default language when not provided
Intl::CLDR enums once available.
- Add tests for major languages
- Fixed a small bug (mod → % for CLDR's mod)
- Updated CLDR reference (was
.plurals in beta, now is
- Initial release as separate module
- v0.1 – v0.5
- Included as a part of
License and Copyright
© 2020-2021 Matthew Stephen Stuckwisch.
Licensed under the Artistic License 2.0.