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

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

pkorniev/yii2-language
======================

Simple language extension for Yii2.

v1.1(4y ago)08MITPHP

Since Feb 14Pushed 4y ago1 watchersCompare

[ Source](https://github.com/pkorniev/language-yii2)[ Packagist](https://packagist.org/packages/pkorniev/yii2-language)[ RSS](/packages/pkorniev-yii2-language/feed)WikiDiscussions master Synced yesterday

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

language-yii2
=============

[](#language-yii2)

Language extension for yii2 application.

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

[](#installation)

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

Either run

```
php composer.phar require  pkorniev/language-yii2

```

or add

```
"pkorniev/language-yii2": ">=1.0"

```

to the require section of your `composer.json` file.

Usage
-----

[](#usage)

Once the extension is installed, you need to override the application components "request" and "urlManager" and add the component "translator" (it will store translation parameters) in the main configuration file :

```
...
'components' => [
        'request' => [
            'class' => 'pkorniev\language\PKRequest',
            // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
            'cookieValidationKey' => '',
        ],
        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'class' => 'pkorniev\language\PKUrlManager',
        ],
        'translator' => [
                    'class' => 'pkorniev\language\PKTranslator',
                    'supportedLanguages' => [
                        'ua' => 'uk-UA',
                        'en' => 'en-US',
                    ],
                    'defaultLanguage' =>'ua',
                    //'cookieRemember' => false,
                    //'expiredLangCookie' => 60*60*24*30,
                ],
...

```

The "supportedLanguages" property specifies a list of supported locales. The keys contain user keys that need to be passed in the query string to go to the corresponding locale.

For example, to switch to English, you can use any key to your liking: "en", "eng" or any other. The link to your site with a transition to any language will look like this:

```
https://site.com/en/ or https://site.com/eng/

```

The "defaultLanguage" property specifies which locale to set as the default. Important! The default locale must be declared in the list of available ones.

The "cookieRemember" property specifies whether or not to store the previously set locale in the Cookies. If it is set to true (the default value), then the locale will be set to the one that was the last time it was changed and does not change even if the user key is not passed in the query string.

Well, the "expiredLangCookie" property sets the expiration date of the last locale in seconds. It can be omitted, by default it is equal to 30 days.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

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

Total

2

Last Release

1698d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d7555aaf0dc7e494546edfabbce9778b1b8daa9f698d57b925f173a6d16feb64?d=identicon)[pkorniev](/maintainers/pkorniev)

---

Top Contributors

[![pkorniev](https://avatars.githubusercontent.com/u/16453005?v=4)](https://github.com/pkorniev "pkorniev (5 commits)")

---

Tags

languageyii2extension

### Embed Badge

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

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

###  Alternatives

[lajax/yii2-translate-manager

Translation management extension for Yii 2

227578.8k13](/packages/lajax-yii2-translate-manager)[cetver/yii2-languages-dispatcher

Sets the web-application language for the Yii framework 2.0

1029.7k](/packages/cetver-yii2-languages-dispatcher)[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)[devgroup/yii2-multilingual

Allows building yii2 apps for multiple languages using regional URL's and domains

152.6k2](/packages/devgroup-yii2-multilingual)[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)
