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

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

simsol/yii2-multilang
=====================

Extensions for multi languages in objects

v1.0.7(4y ago)019PHP

Since Aug 18Pushed 4y ago2 watchersCompare

[ Source](https://github.com/simsol-vn/yii2-multi-lang)[ Packagist](https://packagist.org/packages/simsol/yii2-multilang)[ RSS](/packages/simsol-yii2-multilang/feed)WikiDiscussions master Synced today

READMEChangelog (8)Dependencies (2)Versions (9)Used By (0)

[![Latest Stable Version](https://camo.githubusercontent.com/c6e12b9c51429f3247b680f7818751b34ccdae97fc938c2f50059b25c98501e2/687474703a2f2f706f7365722e707567782e6f72672f73696d736f6c2f796969322d6d756c74696c616e672f76)](https://packagist.org/packages/simsol/yii2-multilang) [![Total Downloads](https://camo.githubusercontent.com/9ee5ccce30b3ee7f7437fae2a3ab1b9baee831e01297aefb4ae9c4060adb19e6/687474703a2f2f706f7365722e707567782e6f72672f73696d736f6c2f796969322d6d756c74696c616e672f646f776e6c6f616473)](https://packagist.org/packages/simsol/yii2-multilang) [![Latest Unstable Version](https://camo.githubusercontent.com/c82ce599b0c5a1b51b118566f66f921deea27dff5a34198355c2d19903c339ae/687474703a2f2f706f7365722e707567782e6f72672f73696d736f6c2f796969322d6d756c74696c616e672f762f756e737461626c65)](https://packagist.org/packages/simsol/yii2-multilang) [![License](https://camo.githubusercontent.com/c877145442a83833aaec2a1ddb413226fd23c867e2a363624d1512b1ebf2baf9/687474703a2f2f706f7365722e707567782e6f72672f73696d736f6c2f796969322d6d756c74696c616e672f6c6963656e7365)](https://packagist.org/packages/simsol/yii2-multilang)

This is a Guide for using MultiLang Module
==========================================

[](#this-is-a-guide-for-using-multilang-module)

### 1. Install

[](#1-install)

```
composer require simsol/yii2-multilang

```

### 2. Init

[](#2-init)

Module declaration and config for languages to be stored:

```
    'modules' => [
        'multilang' => [
            'class'     => 'simsol\multilang\Module',
            //config for languages, default will be ["en"=>"ENG"]."en" is language code and "ENG" is the label to be displayed
            'languages' => [
                'en' => 'ENG',
                'vi' => 'VN',
            ],
        ],
    ],

```

### 3. Run Migrations

[](#3-run-migrations)

```
./yii migrate --migrationPath=@simsol/multilang/migrations

```

### 4. Usage

[](#4-usage)

Please follow below steps to set up and use this extension.

#### a. In model

[](#a-in-model)

- Add property `translation` to your model class.

    ```
    public $translations;

    ```
- Add rule for `translation` property.

    ```
    /**
      * {@inheritdoc}
      */
      public function rules()
      {
         return [
            ...
            [['translations'],'safe'],
         ];
      }

    ```
- Modify `afterSave()` and add this line:

    ```
    Translate::saveTranslation($this->translations,$this->id_model,Model::class);

    ```

    This will save translation for current model.

#### b. In form

[](#b-in-form)

- Add this widget for attributes that you want to provide translation to your create or update form.

    ```

    ```
- Available config:

    - `attributeLabel`: Optional. In case you want to use another name for model attribute, default is model's attribute name.
    - `attributeToSave`: Optional. In case you want to save with a different attribute, default is model's attribute. Useful when working with custom model.
    - `attributeToLoad`: Optional. In case you want to load saved translation value on edit with a different attribute, default is model's attribute. Useful when working with custom model.
    - `inputType`: Optional. Default is text input, available options:
        - Text Input: MultiLangFieldsWidget::TYPE\_TEXT\_INPUT
        - Textarea: MultiLangFieldsWidget::TYPE\_TEXTAREA

    ```

    ```

#### c. Query translations

[](#c-query-translations)

```
 Translate::loadTranslation($model,$attribute = null,$modelId = null;$modelClass = null,$language = null)

```

- `$model`: Required. Model to load translations.
- `$attribute`: Optional. Translations for specified attribute will be queried if provided.
- `$modelId`: Optional. In case the model id is different from defined $model, useful when working with custom model.
- `$modelClass`: Optional. In case model class name is different from provided model. For example: `app\models\form\CustomerForm` and `app\models\Customer`
- `$language`: Optional. If passed, value will be used to query for specified language.
- Query results: Result might be varied depends on provided parameters. See examples below:

```
Translate::loadTranslation($model);

Result:

[
    'description' => [
        'en' => 'Description of data.',
        'vi' => 'Mô tả của dữ liệu',
    ],
    'title' => [
        'en' => 'Title of data',
        'vi' => 'Tiêu đề của dữ liệu',
    ],
]

```

```
Translate::loadTranslation($model,'title');

Result:

[
        'en' => 'Title of data',
        'vi' => 'Tiêu đề của dữ liệu',
]

```

```
Translate::loadTranslation($model,'title',null,null,'en');

Result:

'Title of data'

```

```
Translate::loadTranslation($model,null,null,null,'en');

Result:

[
    'description' => 'Description of data.',
    'title' => 'Title of data',
]

```

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 97.1% 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 ~1 days

Total

8

Last Release

1769d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3130214?v=4)[Thang Dang](/maintainers/vthang87)[@vthang87](https://github.com/vthang87)

---

Top Contributors

[![tamtk92](https://avatars.githubusercontent.com/u/10095451?v=4)](https://github.com/tamtk92 "tamtk92 (33 commits)")[![vthang87](https://avatars.githubusercontent.com/u/3130214?v=4)](https://github.com/vthang87 "vthang87 (1 commits)")

### Embed Badge

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

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

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M3.1k](/packages/craftcms-cms)[skeeks/cms

SkeekS CMS — control panel and tools based on php framework Yii2

13825.8k58](/packages/skeeks-cms)[lajax/yii2-translate-manager

Translation management extension for Yii 2

227597.2k13](/packages/lajax-yii2-translate-manager)[yeesoft/yii2-multilingual

Yii2 Multilingual Module

177.4k1](/packages/yeesoft-yii2-multilingual)

PHPackages © 2026

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