PHPackages                             xz1mefx/yii2-multilang - 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. xz1mefx/yii2-multilang

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

xz1mefx/yii2-multilang
======================

Multilanguage tools package

v1.2.3(9y ago)491MIT

Since Dec 10Compare

[ Source](https://github.com/xZ1mEFx/yii2-multilang)[ Packagist](https://packagist.org/packages/xz1mefx/yii2-multilang)[ RSS](/packages/xz1mefx-yii2-multilang/feed)WikiDiscussions Synced yesterday

READMEChangelog (9)Dependencies (1)Versions (10)Used By (0)

Multilanguage tools package for yii2
====================================

[](#multilanguage-tools-package-for-yii2)

[![Latest Version on Packagist](https://camo.githubusercontent.com/684dc3a06f0eee8c7390c1efde58383a870bfce99b7ab8267ead35ba92432bca/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f787a316d6566782f796969322d6d756c74696c616e672e737667)](https://packagist.org/packages/xz1mefx/yii2-multilang)[![Software License](https://camo.githubusercontent.com/074b89bca64d3edc93a1db6c7e3b1636b874540ba91d66367c0e5e354c56d0ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e737667)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/fcda16f4ce78f88b8550bec48bac82447917993c3531dd065692459afeb7a38a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f787a316d6566782f796969322d6d756c74696c616e672e737667)](https://packagist.org/packages/xz1mefx/yii2-multilang)

The extension is a package of tools to implement multilanguage in Yii2 project:

- Automatically redirects the user to the URL selected (automatically or manually) language and remembers the user selected language
- Automatically collect all new translates into DB
- Has a widget to set a correct hreflang attributes
- Provides a CRUD actions for edit the list of languages and the interface translations
- Has a widget to create language selector (for adminlte theme)
- Has a `@weblang\` alias with current language

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

[](#installation)

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

    ```
    php composer.phar require --prefer-dist xz1mefx/yii2-multilang "~1"
    ```
2. Add new multilangCache component to common config file:

    ```
    'multilangCache' => [
        'class' => \xz1mefx\multilang\caching\MultilangCache::className(),
    ],
    ```
3. Execute migration:

    ```
    php yii migrate --migrationPath=@vendor/xz1mefx/yii2-multilang/migrations --interactive=0
    ```

    or you can create new migration and extend it, example:

    ```
    require(Yii::getAlias('@vendor/xz1mefx/yii2-multilang/migrations/m161210_131014_multilang_init.php'));

    /**
    * Class m161221_135351_multilang_init
    */
    class m161221_135351_multilang_init extends m161210_131014_multilang_init
    {
    }
    ```
4. Override components in common config file:

    ```
    'urlManager' => [
        'class' => \xz1mefx\multilang\web\UrlManager::className(),
    ],
    'request' => [
        'class' => \xz1mefx\multilang\web\Request::className(),
    ],
    'i18n' => [
        'class' => \xz1mefx\multilang\i18n\I18N::className(),
    ],
    'lang' => [
        'class' => \xz1mefx\multilang\components\Lang::className(),
    ],
    ```
5. \[*not necessary*\] If you use [`iiifx-production/yii2-autocomplete-helper`](https://github.com/iiifx-production/yii2-autocomplete-helper) you need to run:
6. Override some components in console config file:

    ```
    'request' => [ // override common config
        'class' => 'yii\console\Request',
    ],
    'urlManager' => [], // override common config
    'i18n' => [], // override common config
    ```
7. Add HrefLangs widget to page `` section in layout(s):

    ```

    ```
8. Add LanguageController (or another) with next code:

    ```
    use xz1mefx\multilang\actions\language\IndexAction;
    use xz1mefx\multilang\actions\language\CreateAction;
    use xz1mefx\multilang\actions\language\UpdateAction;
    use xz1mefx\multilang\actions\language\DeleteAction;

    ...

    /**
     * @inheritdoc
     */
    public function actions()
    {
        return [
            'index' => [
                'class' => IndexAction::className(),
    //          'theme' => IndexAction::THEME_ADMINLTE,
    //          'canAdd' => false,
    //          'canUpdate' => false,
    //          'canDelete' => false,
            ],
            'create' => [
                'class' => CreateAction::className(),
    //          'theme' => CreateAction::THEME_ADMINLTE,
            ],
            'update' => [
                'class' => UpdateAction::className(),
    //           'theme' => UpdateAction::THEME_ADMINLTE,
            ],
            'delete' => [
                'class' => DeleteAction::className(),
    //           'theme' => DeleteAction::THEME_ADMINLTE,
            ],
        ];
    }
    ```

    , where you can change action theme (`THEME_BOOTSTRAP` - *by default* or [`THEME_ADMINLTE`](https://github.com/xZ1mEFx/yii2-adminlte)) , view path and access to controls in index action.

    This controller will control system languages.
9. Add TranslationController (or another) with next code:

    ```
    use xz1mefx\multilang\actions\translation\IndexAction;
    use xz1mefx\multilang\actions\translation\UpdateAction;

    ...

    /**
     * @inheritdoc
     */
    public function actions()
    {
        return [
            'index' => [
                'class' => IndexAction::className(),
    //          'theme' => IndexAction::THEME_ADMINLTE,
    //          'canUpdate' => false,
            ],
            'update' => [
                'class' => UpdateAction::className(),
    //          'theme' => UpdateAction::THEME_ADMINLTE,
            ],
        ];
    }
    ```

    , where you can change action theme (`THEME_BOOTSTRAP` - *by default* or [`THEME_ADMINLTE`](https://github.com/xZ1mEFx/yii2-adminlte)) , view path and access to controls in index action.

    This controller will control interface translations.
10. \[*not necessary, only for adminlte theme*\] Add language selector widget into `header ul.nav`:

    ```

    ```

AdminLTE theme you can found in [`xz1mefx/yii2-adminlte` package](https://github.com/xZ1mEFx/yii2-adminlte).

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity69

Established project with proven stability

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

Total

9

Last Release

3456d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8987a4d88f9496ca176bd20a8a62e96b55c21b3307a70ff659703538fe89ea17?d=identicon)[xZ1mEFx](/maintainers/xZ1mEFx)

---

Tags

languageyii2localelangxZ1mEFx

### Embed Badge

![Health badge](/badges/xz1mefx-yii2-multilang/health.svg)

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

###  Alternatives

[aplus/language

Aplus Framework Language Library

2371.7M15](/packages/aplus-language)[cetver/yii2-languages-dispatcher

Sets the web-application language for the Yii framework 2.0

1030.4k](/packages/cetver-yii2-languages-dispatcher)[tigrov/yii2-country

Country data for Yii2 using Intl extension and more.

151.1k](/packages/tigrov-yii2-country)[jrmajor/fluent

Fluent localization system for PHP

2718.0k7](/packages/jrmajor-fluent)

PHPackages © 2026

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