PHPackages                             oblik/pluralization - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. oblik/pluralization

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

oblik/pluralization
===================

Pluralization according to Unicode

1.4.0(3y ago)03122[1 PRs](https://github.com/oblik/php-pluralization/pulls)1MITPHPCI passing

Since Aug 13Pushed 3w ago5 watchersCompare

[ Source](https://github.com/oblik/php-pluralization)[ Packagist](https://packagist.org/packages/oblik/pluralization)[ RSS](/packages/oblik-pluralization/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (5)Dependencies (1)Versions (8)Used By (1)

Pluralization for PHP
=====================

[](#pluralization-for-php)

This package allows you to get the correct plural form for words based on the Language Plural Rules [defined in Unicode](https://www.unicode.org/cldr/charts/27/supplemental/language_plural_rules.html). You can get forms for cardinal and ordinal numbers, as well as ranges of cardinal numbers.

To check which languages are supported, check the [src folder](src). In you need another language, create an issue or a PR.

Installation
------------

[](#installation)

With [Composer](https://packagist.org/packages/oblik/pluralization):

```
composer require oblik/pluralization

```

Usage
-----

[](#usage)

There are [six plural categories](http://cldr.unicode.org/index/cldr-spec/plural-rules) and each is represented with a constant: `ZERO`, `ONE`, `TWO`, `FEW`, `MANY`, and `OTHER`. You should use those constants in your code:

```
namespace Oblik\Pluralization {
    function place($n)
    {
        $class = LANGUAGES['en'];
        $form = $class::getOrdinal($n);

        switch ($form) {
            case ONE: return "{$n}st";
            case TWO: return "{$n}nd";
            case FEW: return "{$n}rd";
            case OTHER: return "{$n}th";
        }
    }

    echo place(1);    // 1st
    echo place(2);    // 2nd
    echo place(103);  // 103rd
    echo place(14);   // 14th
}
```

API
---

[](#api)

Each language is represented by a class that extends the abstract `Language` class and has the following static methods:

#### `getCardinal($number)`

[](#getcardinalnumber)

Returns the plural form of a cardinal number.

#### `getOrdinal($number)`

[](#getordinalnumber)

Returns the plural form of an ordinal number.

#### `getRange($start, $end)`

[](#getrangestart-end)

Returns the plural form of a range.

#### `formName($form)`

[](#formnameform)

Returns the string name of a form constant.

### Example

[](#example)

```
use Oblik\Pluralization\EnglishLanguage;

EnglishLanguage::getCardinal(0);    // => Oblik\Pluralization\OTHER
EnglishLanguage::getCardinal(1);    // => Oblik\Pluralization\ONE
EnglishLanguage::getCardinal(1.5);  // => Oblik\Pluralization\OTHER
EnglishLanguage::getCardinal(2);    // => Oblik\Pluralization\OTHER

EnglishLanguage::getOrdinal(2);     // => Oblik\Pluralization\TWO
EnglishLanguage::getOrdinal(3);     // => Oblik\Pluralization\FEW
EnglishLanguage::getOrdinal(4);     // => Oblik\Pluralization\OTHER
EnglishLanguage::getOrdinal(103);   // => Oblik\Pluralization\FEW

EnglishLanguage::getRange(0, 2);    // => Oblik\Pluralization\OTHER
EnglishLanguage::getRange(1, 2);    // => Oblik\Pluralization\OTHER

EnglishLanguage::formName(Oblik\Pluralization\ZERO);    // => "zero"
EnglishLanguage::formName(Oblik\Pluralization\ONE);     // => "one"
```

To get the correct language class based on a language code, use the `LANGUAGES` constant:

```
use const Oblik\Pluralization\LANGUAGES;

$lang = LANGUAGES['en'];  // => "Oblik\Pluralization\EnglishLanguage"
$lang::getCardinal(1);    // => Oblik\Pluralization\ONE
```

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance62

Regular maintenance activity

Popularity15

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~258 days

Total

5

Last Release

1435d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/078077710a1481f0419521ab1e1d3e5f93723aadd56148937ee3e355b93acb2e?d=identicon)[hdodov](/maintainers/hdodov)

---

Top Contributors

[![nikitos-mv](https://avatars.githubusercontent.com/u/46297434?v=4)](https://github.com/nikitos-mv "nikitos-mv (43 commits)")[![neildaniels](https://avatars.githubusercontent.com/u/417182?v=4)](https://github.com/neildaniels "neildaniels (41 commits)")[![yandodov](https://avatars.githubusercontent.com/u/5570098?v=4)](https://github.com/yandodov "yandodov (15 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/oblik-pluralization/health.svg)

```
[![Health](https://phpackages.com/badges/oblik-pluralization/health.svg)](https://phpackages.com/packages/oblik-pluralization)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
