PHPackages                             wapmorgan/yii2-inflection - 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. wapmorgan/yii2-inflection

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

wapmorgan/yii2-inflection
=========================

Inflection extension for Yii2. Support for English / Russian languages to inflect words / names / numbers / money / date&amp;time.

1.0.4(8y ago)32112.3k↑17.4%8[1 PRs](https://github.com/wapmorgan/yii2-inflection/pulls)GPL-3.0-onlyPHP

Since Aug 12Pushed 6y ago1 watchersCompare

[ Source](https://github.com/wapmorgan/yii2-inflection)[ Packagist](https://packagist.org/packages/wapmorgan/yii2-inflection)[ RSS](/packages/wapmorgan-yii2-inflection/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (3)Versions (6)Used By (0)

yii2-inflection
===============

[](#yii2-inflection)

Inflection *extension* for Yii2. Support for English / Russian languages to inflect words / names / numbers / money / date&amp;time.

[![Latest Stable Version](https://camo.githubusercontent.com/b4e4424e4f95d1dc1204eaf98d9b43246ada5b49e791d1fe6135438ee4c2a41e/68747470733a2f2f706f7365722e707567782e6f72672f7761706d6f7267616e2f796969322d696e666c656374696f6e2f762f737461626c65)](https://packagist.org/packages/wapmorgan/yii2-inflection)[![License](https://camo.githubusercontent.com/d30394d26d7613f07f24fe91732a96f9de385999c41d950d3edfb242b0f435a2/68747470733a2f2f706f7365722e707567782e6f72672f7761706d6f7267616e2f796969322d696e666c656374696f6e2f6c6963656e7365)](https://packagist.org/packages/wapmorgan/yii2-inflection)[![Testing](https://camo.githubusercontent.com/514fcd3fafc91b6cb4168a6c4e6f0bbae82c96fa5f43f97fcef060abdccc81a1/68747470733a2f2f7472617669732d63692e6f72672f7761706d6f7267616e2f796969322d696e666c656374696f6e2e737667)](https://travis-ci.org/wapmorgan/yii2-inflection)

1. [Features](#features)
    - [Cases](#cases)
    - [Currencies](#currencies)
2. [How does it work](#how-does-it-work)
3. [Installation](#installation)

Features
--------

[](#features)

1. **Pluralize word with number**:

- `en`: `Yii::$app->inflection->pluralize(2, 'item')` =&gt; `2 items`
- `ru`: `Yii::$app->inflection->pluralize(2, 'элемент')` =&gt; `2 элемента`

2. **Inflect names to relational cases (applicable in Russian only)**:

- `ru`: `Yii::$app->inflection->inflectName('Иванов Петр', wapmorgan\yii2inflection\Inflector::DATIVE)` =&gt; `Иванову Петру`
- *Description of all supported cases are in [Cases](#cases) section.*

3. **Inflect geographical names to relational cases (applicable in Russian only)**:

- `ru`: `Yii::$app->inflection->inflectGeoName('Санкт-Петербург', wapmorgan\yii2inflection\Inflector::GENITIVE)` =&gt; `Санкт-Петербурга`

4. **Generate cardinal numerals**:

- `en`: `Yii::$app->inflection->cardinalize(2)` =&gt; 'two'
- `ru`: `Yii::$app->inflection->cardinalize(2)` =&gt; 'два'

5. **Generate ordinal numerals**:

- `en`: `Yii::$app->inflection->ordinalize(2)` =&gt; '2nd'
- `ru`: `Yii::$app->inflection->ordinalize(2)` =&gt; '2-й'

And full form:

- `en`: `Yii::$app->inflection->ordinalize(2, wapmorgan\yii2inflection\Inflector::FULL)` =&gt; 'second'
- `ru`: `Yii::$app->inflection->ordinalize(2, wapmorgan\yii2inflection\Inflector::FULL)` =&gt; 'второй'

6. **Money to words**:

- (*WIP*) `en`: `Yii::$app->inflection->monetize(wapmorgan\yii2inflection\Inflector::DOLLAR, 122.04)` =&gt; 'one hundred twenty-two dollars four cents'
- `ru`: `Yii::$app->inflection->monetize(wapmorgan\yii2inflection\Inflector::DOLLAR, 122.04)` =&gt; 'сто двадцать два доллара четыре цента'
- *Description of all supported currencies are in [Currencies](#currencies) section.*

7. **Data range to words**:

- `en`: `Yii::$app->inflection->textizeTimeRange(new DateInterval('P2Y'))` =&gt; '2 years'
- `ru`: `Yii::$app->inflection->textizeTimeRange(new DateInterval('P2Y'))` =&gt; '2 года'

*WIP* means Work-in-progress i.e this feature is not supported now, but planned to be implemented.

### Cases

[](#cases)

CaseRussian`Inflector::NOMINATIVE`Именительный`Inflector::ABLATIVE`Творительный`Inflector::ACCUSATIVE`Винительный`Inflector::AVERSIVE``Inflector::BENEFACTIVE``Inflector::CAUSAL``Inflector::COMITATIVE``Inflector::DATIVE`Дательный`Inflector::DISTRIBUTIVE``Inflector::GENITIVE`Родительный`Inflector::ORNATIVE``Inflector::POSSESSED``Inflector::POSSESSIVE``Inflector::PREPOSITIONAL`Предложный`Inflector::PRIVATIVE``Inflector::SEMBLATIVE``Inflector::SOCIATIVE`### Currencies

[](#currencies)

Currency`Inflector::DOLLAR``Inflector::EURO``Inflector::YEN``Inflector::POUND``Inflector::FRANC``Inflector::YUAN``Inflector::KRONA``Inflector::PESO``Inflector::WON``Inflector::LIRA``Inflector::RUBLE``Inflector::RUPEE``Inflector::REAL``Inflector::RAND``Inflector::HRYVNIA`How does it work
----------------

[](#how-does-it-work)

It uses built-in inflector for English pluralization (`yii\helpers\Inflector`) and [Morphos](https://github.com/wapmorgan/Morphos) for English &amp; Russian on-the-fly inflection (without dictionaries).

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

[](#installation)

1. Install extension

```
composer require wapmorgan/yii2-inflection
```

2. Add `wapmorgan\yii2inflection\Inflection` as a service `inflection` in config and specify proper target language of your application (**web.php** or **console.php**):

```
$config = [
  // ...
  'language' => 'ru_RU', // for example, Russian
  // ...
  'components' => [
    // ...
    'inflection' => [
      'class' => 'wapmorgan\yii2inflection\Inflection'
    ]
  ],
  // ...
];
```

- Optional service parameters:
    - `language` - default language for inflection. By default, it uses **language** parameter of current application, but you can change this behavior. Currently supported langs is `ru` (Russian) and `en` (English) or their's modification (`ru_RU`, `en_US`). If you pass unsupported or unknown language, an Exception will be thrown during service initializion.
    - `defaultCurrency` - default currency when converting money to words. If set, you can call `monetize(float $value)` without currency: `Yii::$app->inflection->monetize(123.45)` =&gt; `сто двадцать три рубля сорок пять копеек`

3. Call any methods described above in a controller / command / view.

```
$word = 'новость';
echo Yii::$app->inflection->pluralize(rand(2, 139), $word).PHP_EOL;
echo Yii::$app->inflection->pluralize(rand(9, 69), $word).PHP_EOL;
```

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity43

Moderate usage in the ecosystem

Community10

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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 ~56 days

Total

5

Last Release

2976d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6000618?v=4)[Sergey](/maintainers/wapmorgan)[@wapmorgan](https://github.com/wapmorgan)

---

Top Contributors

[![wapmorgan](https://avatars.githubusercontent.com/u/6000618?v=4)](https://github.com/wapmorgan "wapmorgan (48 commits)")

---

Tags

inflectionyii2englishrussian

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/wapmorgan-yii2-inflection/health.svg)

```
[![Health](https://phpackages.com/badges/wapmorgan-yii2-inflection/health.svg)](https://phpackages.com/packages/wapmorgan-yii2-inflection)
```

###  Alternatives

[wapmorgan/morphos

A morphological solution for Russian and English language written completely in PHP. Provides classes to inflect personal names, geographical names, decline and pluralize nouns, generate cardinal and ordinal numerals, spell out money amounts and time.

8351.3M7](/packages/wapmorgan-morphos)[hackzilla/ticket-bundle

This Bundle provides multilingual ticketing functionality for Symfony applications.

6529.3k1](/packages/hackzilla-ticket-bundle)[dmstr/yii2-cookie-consent

Yii2 Cookie Consent Widget

1452.6k](/packages/dmstr-yii2-cookie-consent)

PHPackages © 2026

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