PHPackages                             devgroup/yii2-multilingual - 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. [Localization &amp; i18n](/categories/localization)
4. /
5. devgroup/yii2-multilingual

ActiveYii2-extension[Localization &amp; i18n](/categories/localization)

devgroup/yii2-multilingual
==========================

Allows building yii2 apps for multiple languages using regional URL's and domains

0.2.1(9y ago)152.6k8[12 issues](https://github.com/DevGroup-ru/yii2-multilingual/issues)1MITPHP

Since May 27Pushed 9y ago9 watchersCompare

[ Source](https://github.com/DevGroup-ru/yii2-multilingual)[ Packagist](https://packagist.org/packages/devgroup/yii2-multilingual)[ Docs](http://www.devgroup.ru/)[ RSS](/packages/devgroup-yii2-multilingual/feed)WikiDiscussions master Synced today

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

Yii2 multilingual component
===========================

[](#yii2-multilingual-component)

Allows building yii2 apps for multiple languages using regional URL's and domains

[![Build Status](https://camo.githubusercontent.com/60f4de4cb40cd6548bd8237db1b2deb8e44c5d5f4a9dd758f51329183e553d4d/68747470733a2f2f7472617669732d63692e6f72672f44657647726f75702d72752f796969322d6d756c74696c696e6775616c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/DevGroup-ru/yii2-multilingual)[![codecov.io](https://camo.githubusercontent.com/ca6ce94a65fe306a2a1e929c57c90d5031106f26967470598d2fba11f265fa58/687474703a2f2f636f6465636f762e696f2f6769746875622f44657647726f75702d72752f796969322d6d756c74696c696e6775616c2f636f7665726167652e7376673f6272616e63683d6d6173746572)](http://codecov.io/github/DevGroup-ru/yii2-multilingual?branch=master)

Quick start:

- [Demo Application](https://github.com/DevGroup-ru/yii2-multilingual-demo)
- [GEO detection daemon](https://github.com/DevGroup-ru/sypex-geo-daemon) and [related multilingual provider](https://github.com/DevGroup-ru/yii2-multilingual-sypex-geo-daemon).

**WARNING:** This extension is under active development.

For support - join [DotPlant2 gitter channel](https://gitter.im/DevGroup-ru/dotplant2).

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

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist devgroup/yii2-multilingual "*"

```

or add

```
"devgroup/yii2-multilingual": "*"

```

to the require section of your `composer.json` file.

Usage
-----

[](#usage)

### Configure your application

[](#configure-your-application)

In your `web.php` config add the following components:

```
        // URL Manager is needed to build correct URL's
        'urlManager' => [
            'class' => \DevGroup\Multilingual\components\UrlManager::className(),
            'excludeRoutes' => [
                //'newsletter/index',
                //'newsletter/test',
            ],
            'rules' => [
                '' => 'post/index',
            ],
        ],
        // this is the main language and geo detection component
        'multilingual' => [
            'class' => \DevGroup\Multilingual\Multilingual::className(),
            // the list of handlers that will try to detect information(see also sypex-geo-daemon provider)
            'handlers' => [
                [
                    'class' => \DevGroup\Multilingual\DefaultGeoProvider::className(),
                    'default' => [
                        'country' => [
                            'name' => 'England',
                            'iso' => 'en',
                        ],
                    ],
                ],
            ],
        ],
        // this is simple storage for Languages configuration
        'filedb' => [
            'class' => 'yii2tech\filedb\Connection',
            'path' => __DIR__ . '/data',
        ],
```

### Creating translatable ActiveRecord

[](#creating-translatable-activerecord)

As our implementation is based on `creocoder/yii2-translatable` - the use creation of multilingual ActiveRecords is very similar.

The main differences from `creocoder2/yii2translatable`:

- no need to set `translationAttributes` - they automatically detected from translation model
- language field is `language_id` of integer type

In your ActiveRecord class(for example `Post`) add trait and behavior:

```
use DevGroup\Multilingual\behaviors\MultilingualActiveRecord;
use DevGroup\Multilingual\traits\MultilingualTrait;

/**
 * Class Post
 * @property integer $author_id
 */
class Post extends \yii\db\ActiveRecord
{
    use MultilingualTrait;

    /**
     * @inheritdoc
     */
    public function behaviors()
    {
        return [
            'multilingual' => [
                'class' => MultilingualActiveRecord::className(),
                'translationPublishedAttribute' => 'is_active',
            ],
        ];
    }

    public static function tableName()
    {
        return '{{%post}}';
    }
}
```

### HrefLang

[](#hreflang)

Add one line into your HEAD section of layout view:

```

```

Tips
----

[](#tips)

1. Remember to take care of language\_id when caching multilingual or translatable content
2. In requests to excluded routes there may be no `language_id`, but probably can be `cookie_language_id`
3. If you want to generate URL's from console application you may need to configure additional params(see )
4. MultilingualTrait adds default conditions to find and is not required for use. But if you don't use it - you must manually configure proper relations.
5. Add indexes to your translation tables, especially for `language_id` and `model_id` pair.

Credits and inspiration sources
-------------------------------

[](#credits-and-inspiration-sources)

- Michael Härtl - author of codemix/yii2-localeurls
- Company BINOVATOR - authors of SypexGeo database and php class
- Alexander Kochetov (@creocoder) - yii2-translatable package

###  Health Score

29

—

LowBetter than 63% of packages

Maintenance4

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 68.3% 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 ~75 days

Total

3

Last Release

3435d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/19c9303caa5846f2500a35018dcbd3c7f07c74e30efc1bbf7878d54157ab9c4f?d=identicon)[bethrezen](/maintainers/bethrezen)

---

Top Contributors

[![bethrezen](https://avatars.githubusercontent.com/u/260284?v=4)](https://github.com/bethrezen "bethrezen (69 commits)")[![Hector68](https://avatars.githubusercontent.com/u/920564?v=4)](https://github.com/Hector68 "Hector68 (20 commits)")[![fps01](https://avatars.githubusercontent.com/u/2114997?v=4)](https://github.com/fps01 "fps01 (11 commits)")[![socana](https://avatars.githubusercontent.com/u/6152456?v=4)](https://github.com/socana "socana (1 commits)")

---

Tags

i18nlanguagel10nmultilingualyii2extensionhreflang

### Embed Badge

![Health badge](/badges/devgroup-yii2-multilingual/health.svg)

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

###  Alternatives

[lajax/yii2-translate-manager

Translation management extension for Yii 2

227573.2k13](/packages/lajax-yii2-translate-manager)[omgdef/yii2-multilingual-behavior

Port of the yii-multilingual-behavior for yii

143172.0k9](/packages/omgdef-yii2-multilingual-behavior)[inpsyde/multilingual-press

Simply THE multisite-based free open source plugin for your multilingual websites.

2414.0k1](/packages/inpsyde-multilingual-press)[yeesoft/yii2-multilingual

Yii2 Multilingual Module

177.4k1](/packages/yeesoft-yii2-multilingual)[tigrov/yii2-country

Country data for Yii2 using Intl extension and more.

151.1k](/packages/tigrov-yii2-country)[exploreimpact/contao-i18nl10n

The simplest way to create and manage multi-language sites with Contao.

201.4k](/packages/exploreimpact-contao-i18nl10n)

PHPackages © 2026

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