PHPackages                             lajax/yii2-language-picker - 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. lajax/yii2-language-picker

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

lajax/yii2-language-picker
==========================

Yii2 Language Picker Widget

1.2.1(8y ago)41230.8k↓27.9%25[3 issues](https://github.com/lajax/yii2-language-picker/issues)[2 PRs](https://github.com/lajax/yii2-language-picker/pulls)3BSD-3-ClauseCSS

Since Mar 1Pushed 7y ago11 watchersCompare

[ Source](https://github.com/lajax/yii2-language-picker)[ Packagist](https://packagist.org/packages/lajax/yii2-language-picker)[ RSS](/packages/lajax-yii2-language-picker/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (10)Used By (3)

Yii2 Language Picker
====================

[](#yii2-language-picker)

Yii2 Language Picker Widget

Introduction
------------

[](#introduction)

The widget provides an easy to use language selector which makes it possible to change the language of our website easily. The language change can take place synchronously or asynchronously (through Ajax). The default method is asynchronous (through an Ajax call), however when this method fails for any reason (e.g. JavaScript is blocked on the client side) the new language will actualise synchronously through an automatic page reload.

The language switcher is fully customisable. However, the pre-defined options provide a dropdown list (DropDownList), and a link-based list (ButtonList). Both versions can display the name of the chosen language and the corresponding flag (icon).

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

[](#installation)

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

```
composer require lajax/yii2-language-picker
```

Config:
-------

[](#config)

Identifier of the language element. e.g.: en, en-US

### IMPORTANT

[](#important)

To use the widget, the value of the enablePrettyUrl property in the urlManager configuration must be true, and the value of showScriptName false.

example:

```
'components' => [
    // ...
    'urlManager' => [
        'enablePrettyUrl' => true,
        'showScriptName' => false,
        'rules' => [
            // your rules go here
        ],
        // ...
    ],
    // ...
]
```

Using of [urlManager](http://www.yiiframework.com/doc-2.0/yii-web-urlmanager.html).

### Minimal configuration (icons only)

[](#minimal-configuration-icons-only)

```
'language' => 'en',
'bootstrap' => ['languagepicker'],
'components' => [
    'languagepicker' => [
        'class' => 'lajax\languagepicker\Component',
        // List of available languages (icons only)
        'languages' => ['en', 'de', 'fr'],
    ]
],
```

### Minimal configuration (icons and text)

[](#minimal-configuration-icons-and-text)

```
'language' => 'en',
'bootstrap' => ['languagepicker'],
'components' => [
    'languagepicker' => [
        'class' => 'lajax\languagepicker\Component',
        // List of available languages (icons and text)
        'languages' => ['en' => 'English', 'de' => 'Deutsch', 'fr' => 'Français']
    ]
],
```

### Full configuration (icons only)

[](#full-configuration-icons-only)

```
'language' => 'en-US',
'bootstrap' => ['languagepicker'],
'components' => [
    'languagepicker' => [
        'class' => 'lajax\languagepicker\Component',
        'languages' => ['en-US', 'de-DE', 'fr-FR'], // List of available languages (icons only)
        'cookieName' => 'language', // Name of the cookie.
        'cookieDomain' => 'example.com', // Domain of the cookie.
        'expireDays' => 64, // The expiration time of the cookie is 64 days.
        // Function to execute after changing the language
        'callback' => function() {
            if (!\Yii::$app->user->isGuest) {
                $user = \Yii::$app->user->identity;
                $user->language = \Yii::$app->language;
                $user->save();
            }
        }
    ]
],
```

### [Yii2-translate-manager](https://github.com/lajax/yii2-translate-manager) integration

[](#yii2-translate-manager-integration)

#### Minimal configuration (icons only)

[](#minimal-configuration-icons-only-1)

```
'language' => 'en',
'bootstrap' => ['languagepicker'],
'components' => [
    'languagepicker' => [
        'class' => 'lajax\languagepicker\Component',
        // Get available languages from translate manager
        'languages' => function () {
            return array_keys(\lajax\translatemanager\models\Language::getLanguageNames(true));
        }
    ]
],
```

#### Minimal configuration (icons and text)

[](#minimal-configuration-icons-and-text-1)

```
'language' => 'en',
'bootstrap' => ['languagepicker'],
'components' => [
    'languagepicker' => [
        'class' => 'lajax\languagepicker\Component',
        // Get available languages from translate manager
        'languages' => function () {
            return \lajax\translatemanager\models\Language::getLanguageNames(true);
        }
    ]
],
```

Usage
-----

[](#usage)

Displaying language selector
----------------------------

[](#displaying-language-selector)

#### Displaying pre-defined languate picker buttons (icons and text or icons only):

[](#displaying-pre-defined-languate-picker-buttons-icons-and-text-or-icons-only)

```

```

#### Displaying pre-defined languate picker dropdown list (icons and text or icons only):

[](#displaying-pre-defined-languate-picker-dropdown-list-icons-and-text-or-icons-only)

```

```

#### Customising the language picker:

[](#customising-the-language-picker)

```

```

Screenshots
-----------

[](#screenshots)

### Buttons icons and text

[](#buttons-icons-and-text)

[![language-picker-0 2-screen-1](https://camo.githubusercontent.com/dd60dc74b5b8aeb77d0701ff6c8728326dd236addefdb6d68174583626db171f/68747470733a2f2f7265732e636c6f7564696e6172792e636f6d2f6c616a61782f696d6167652f75706c6f61642f76313432333539303830302f627574746f6e2d69636f6e732d616e642d746578745f6161386d62702e706e67)](https://camo.githubusercontent.com/dd60dc74b5b8aeb77d0701ff6c8728326dd236addefdb6d68174583626db171f/68747470733a2f2f7265732e636c6f7564696e6172792e636f6d2f6c616a61782f696d6167652f75706c6f61642f76313432333539303830302f627574746f6e2d69636f6e732d616e642d746578745f6161386d62702e706e67)

### Buttons icons only

[](#buttons-icons-only)

[![language-picker-0 2-screen-2](https://camo.githubusercontent.com/5a6185df176686d846b28422f60b6143f2d533c095a53706b99eaa65d1853208/687474703a2f2f7265732e636c6f7564696e6172792e636f6d2f6c616a61782f696d6167652f75706c6f61642f76313432333539303830332f627574746f6e2d69636f6e732d6f6e6c795f6c726c6973312e706e67)](https://camo.githubusercontent.com/5a6185df176686d846b28422f60b6143f2d533c095a53706b99eaa65d1853208/687474703a2f2f7265732e636c6f7564696e6172792e636f6d2f6c616a61782f696d6167652f75706c6f61642f76313432333539303830332f627574746f6e2d69636f6e732d6f6e6c795f6c726c6973312e706e67)

### Buttons text only

[](#buttons-text-only)

[![language-picker-0 2-screen-3](https://camo.githubusercontent.com/cd73828cdea623b253b48a04c6989a8f2aa6d3238934e9c44b7d4bfd973da0a1/68747470733a2f2f7265732e636c6f7564696e6172792e636f6d2f6c616a61782f696d6167652f75706c6f61642f76313432333939383936352f627574746f6e2d746578742d6f6e6c795f7a616479766f2e706e67)](https://camo.githubusercontent.com/cd73828cdea623b253b48a04c6989a8f2aa6d3238934e9c44b7d4bfd973da0a1/68747470733a2f2f7265732e636c6f7564696e6172792e636f6d2f6c616a61782f696d6167652f75706c6f61642f76313432333939383936352f627574746f6e2d746578742d6f6e6c795f7a616479766f2e706e67)

### DropDown icons and text

[](#dropdown-icons-and-text)

[![language-picker-0 2-screen-4](https://camo.githubusercontent.com/b64fcea2db7ddbe2ea4d2140a7dd785906f3b8273bdfcffcdbc501af40456d22/68747470733a2f2f7265732e636c6f7564696e6172792e636f6d2f6c616a61782f696d6167652f75706c6f61642f76313432333530383832362f64726f70646f776e2d69636f6e732d616e642d746578745f6c67686538762e706e67)](https://camo.githubusercontent.com/b64fcea2db7ddbe2ea4d2140a7dd785906f3b8273bdfcffcdbc501af40456d22/68747470733a2f2f7265732e636c6f7564696e6172792e636f6d2f6c616a61782f696d6167652f75706c6f61642f76313432333530383832362f64726f70646f776e2d69636f6e732d616e642d746578745f6c67686538762e706e67)

### DropDown icons only

[](#dropdown-icons-only)

[![language-picker-0 2-screen-5](https://camo.githubusercontent.com/a2d4d21a29fe578a12b629a076ac1c4a6cd9f7e309e8cdbf46f8e79860d1750d/68747470733a2f2f7265732e636c6f7564696e6172792e636f6d2f6c616a61782f696d6167652f75706c6f61642f76313432333530383832362f64726f70646f776e2d69636f6e732d6f6e6c795f767a716b736c2e706e67)](https://camo.githubusercontent.com/a2d4d21a29fe578a12b629a076ac1c4a6cd9f7e309e8cdbf46f8e79860d1750d/68747470733a2f2f7265732e636c6f7564696e6172792e636f6d2f6c616a61782f696d6167652f75706c6f61642f76313432333530383832362f64726f70646f776e2d69636f6e732d6f6e6c795f767a716b736c2e706e67)

### DropDown text only

[](#dropdown-text-only)

[![language-picker-0 2-screen-5](https://camo.githubusercontent.com/04d79e0012f5a763d0f1a29b2f0fc50e548f64f74668b66ac057bc96ee69bb78/68747470733a2f2f7265732e636c6f7564696e6172792e636f6d2f6c616a61782f696d6167652f75706c6f61642f76313432333939393438362f64726f70646f776e2d746578742d6f6e6c795f6b70306c79742e706e67)](https://camo.githubusercontent.com/04d79e0012f5a763d0f1a29b2f0fc50e548f64f74668b66ac057bc96ee69bb78/68747470733a2f2f7265732e636c6f7564696e6172792e636f6d2f6c616a61782f696d6167652f75706c6f61642f76313432333939393438362f64726f70646f776e2d746578742d6f6e6c795f6b70306c79742e706e67)

Links
-----

[](#links)

- [GitHub](https://github.com/lajax/yii2-language-picker)
- [Api Docs](http://lajax.github.io/yii2-language-picker)
- [Packagist](https://packagist.org/packages/lajax/yii2-language-picker)
- [Yii Extensions](http://www.yiiframework.com/extension/yii2-language-picker)
- [Flag Sprites](http://www.flag-sprites.com)

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity47

Moderate usage in the ecosystem

Community23

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 55.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 ~140 days

Recently: every ~270 days

Total

9

Last Release

2976d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/92584220fadca858bc97cc515957be2a1058a58ff95adde7a3c076d3eb7e1026?d=identicon)[lajax](/maintainers/lajax)

---

Top Contributors

[![lajax](https://avatars.githubusercontent.com/u/5390245?v=4)](https://github.com/lajax "lajax (26 commits)")[![moltam](https://avatars.githubusercontent.com/u/4578365?v=4)](https://github.com/moltam "moltam (12 commits)")[![alexandernst](https://avatars.githubusercontent.com/u/89727?v=4)](https://github.com/alexandernst "alexandernst (9 commits)")

---

Tags

translateyii2extensionmultilanguagewidgetsamplelanguagepicker

###  Code Quality

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/lajax-yii2-language-picker/health.svg)

```
[![Health](https://phpackages.com/badges/lajax-yii2-language-picker/health.svg)](https://phpackages.com/packages/lajax-yii2-language-picker)
```

###  Alternatives

[lajax/yii2-translate-manager

Translation management extension for Yii 2

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

Port of the yii-multilingual-behavior for yii

143174.9k9](/packages/omgdef-yii2-multilingual-behavior)[lav45/yii2-translated-behavior

This extension allows you to quickly and simple enough to add translations for any ActiveRecord models.

3742.2k](/packages/lav45-yii2-translated-behavior)[geertw/yii2-translatable-url-rule

A custom URL rule class for Yii 2 which allows to create translated URL rules

1420.3k](/packages/geertw-yii2-translatable-url-rule)[yeesoft/yii2-multilingual

Yii2 Multilingual Module

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

PHPackages © 2026

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