PHPackages                             abcms/yii2-multilanguage - 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. abcms/yii2-multilanguage

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

abcms/yii2-multilanguage
========================

v0.4.0(6y ago)48133[1 issues](https://github.com/dsoft/yii2-abcms-multilanguage/issues)1PHP

Since Dec 14Pushed 5y ago1 watchersCompare

[ Source](https://github.com/dsoft/yii2-abcms-multilanguage)[ Packagist](https://packagist.org/packages/abcms/yii2-multilanguage)[ RSS](/packages/abcms-yii2-multilanguage/feed)WikiDiscussions master Synced 3w ago

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

Yii2 ABCMS Multi-Language Component
===================================

[](#yii2-abcms-multi-language-component)

Features:
---------

[](#features)

- Add a language bar widget to your website
- Translate models
- Manage languages from database or configuration
- Message translation CRUD

Install:
--------

[](#install)

```
composer require abcms/yii2-library:dev-master
composer require abcms/yii2-multilanguage:dev-master
```

Enable multi-language support in your website:
----------------------------------------------

[](#enable-multi-language-support-in-your-website)

### 1. Add language and sourceLanguage attributes to your config array.

[](#1-add-language-and-sourcelanguage-attributes-to-your-config-array)

```
$config = [
    ......
    'language' => 'en',
    'sourceLanguage' => 'en',
    ......
];
```

### 2. Add multilanguage component

[](#2-add-multilanguage-component)

```
[
    'components' => [
        ......
        'multilanguage' => [
            'class' => 'abcms\multilanguage\Multilanguage',
            'languages' => [
                'en' => 'English',
                'ar' => 'Arabic',
                'fr' => 'French',
            ],
        ],
    ],
]
```

Add the component to the bootstrap array to allow it to read and set the language from cookies and URL:

```
'bootstrap' => ['log', 'multilanguage'],
```

### 3. Add custom URL manager:

[](#3-add-custom-url-manager)

This URL manager class will automatically add the language to each URL.

```
'urlManager' => [
      'class' => abcms\multilanguage\UrlManager::className(),
      'enablePrettyUrl' => true,
      'showScriptName' => false,
      'rules' => [
          '///' => '/',
      ],
],
```

### 4. Add a language switcher to the layout.

[](#4-add-a-language-switcher-to-the-layout)

Using the language bar widget:

```

```

or manually:

```
