PHPackages                             ziya/yii2-translate - 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. ziya/yii2-translate

ActiveLibrary[Localization &amp; i18n](/categories/localization)

ziya/yii2-translate
===================

Translatable

0.2.2(5y ago)237PHPPHP &gt;=7.1.0

Since Nov 22Pushed 5y agoCompare

[ Source](https://github.com/ZiyaVakhobov/yii2-translatable)[ Packagist](https://packagist.org/packages/ziya/yii2-translate)[ RSS](/packages/ziya-yii2-translate/feed)WikiDiscussions master Synced 2d ago

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

Translatable
============

[](#translatable)

You Have to use `PHP 7.1` at least
----------------------------------

[](#you-have-to-use-php-71-at-least)

Widget for Yii2 framework projects. To Json Translate.
------------------------------------------------------

[](#widget-for-yii2-framework-projects-to-json-translate)

`composer require ziya/yii2-translate "^0.2.1"`

Migrations
----------

[](#migrations)

`Attribute that you want translatable should be json field`

```
  $this->createTable('{{%article}}', [
            'id' => $this->primaryKey(),
            'name' => $this->json(),
            ....
        ]);

```

Active Records
--------------

[](#active-records)

Your model should use trait Translatable.

```
use Translatable;

```

If you want to make them required by language then use TranslatableValidator rule then provide what language is required

```
TranslatableValidator::class

```

You have to use TranslatableBehaviour class and show which attribute should follow translatable ```
TranslatableBehaviour::class

```

All code is below with examples
```
class Article extends ActiveRecord
{
    use Translatable;

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['name'], TranslatableValidator::class, 'languages' => ['uz','ru']],
            [['description'],'safe'],
        ];
    }

    public function behaviors()
    {
        return [
            [
                'class' => TranslatableBehaviour::class,
                'attributes' => ['name'']
            ],
        ];
    }

```

View File
---------

[](#view-file)

Your Form will look like this. Give languageList as array.

```
$languageList = ['eng','ru','fr'];

foreach ($languageList as $lang) {
        echo $form
            ->field($model, "name[{$lang}]")
            ->textInput(['value'=>$model->name->other($lang)])
            ->label($model->getAttributeLabel('name') . "_{$lang}");
}

```

Forms
=====

[](#forms)

### If you are using Form instead of ActiveRecord. You need to set type to Model.

[](#if-you-are-using-form-instead-of-activerecord-you-need-to-set-type-to-model)

By default it is TYPE\_ACTIVE\_RECORD, so you need to set TYPE\_MODEL. See below how it is done

```
class ArticleForm extends Model
{

    public $content;
    public function behaviors()
    {
        return [
            'translatable'=>[
                'class' => TranslatableBehaviour::className(),
                'attributes' => ['content'],
                'type' => TranslatableBehaviour::TYPE_MODEL,
            ],
        ];
    }

```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

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

Total

4

Last Release

2178d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2f65e0b705d1efcb5b837481f9203cde712ff03f20e6eb393bc9facbd0115c73?d=identicon)[ZiyaVakhobov](/maintainers/ZiyaVakhobov)

---

Top Contributors

[![ZiyaVakhobov](https://avatars.githubusercontent.com/u/26081148?v=4)](https://github.com/ZiyaVakhobov "ZiyaVakhobov (17 commits)")

### Embed Badge

![Health badge](/badges/ziya-yii2-translate/health.svg)

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

###  Alternatives

[tigrov/yii2-country

Country data for Yii2 using Intl extension and more.

151.1k](/packages/tigrov-yii2-country)

PHPackages © 2026

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