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

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

motion/yii2-language-provider
=============================

This package provides interface for language provider for Yii2 Framework

2.1.0(8y ago)520.1k↓33.3%[2 issues](https://github.com/motion-web-production/yii2-language-provider/issues)1BSD-3-ClausePHP

Since Nov 2Pushed 7y ago1 watchersCompare

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

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

Language provider interface
===========================

[](#language-provider-interface)

This package provides interface for language provider for accessing application languages from any storage for Yii2 Framework. It's allows to you create multi-language modules for using in Yii2 based application. As example of integration to module you can see [yii2-email-template](https://github.com/yiimaker/yii2-email-templates) extension.

[![Latest Stable Version](https://camo.githubusercontent.com/c67b8bbd69b61ce5e605005e17787dfdbd8adaa84c5b3d035c4b3feadbd4f909/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6f74696f6e2f796969322d6c616e67756167652d70726f76696465722e737667)](CHANGELOG.md)[![Monthly Downloads](https://camo.githubusercontent.com/d1ae50fbbf04f8c2bca8b9a8b9aa14e17f8b93cd6861092016750101126c128d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6d6f74696f6e2f796969322d6c616e67756167652d70726f76696465722e737667)](https://packagist.org/packages/motion/yii2-language-provider)[![Total Downloads](https://camo.githubusercontent.com/b540a8e892423668b93771f7fc4a910de3648be598b61826d72fefe4471fc44f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6f74696f6e2f796969322d6c616e67756167652d70726f76696465722e737667)](https://packagist.org/packages/motion/yii2-language-provider)[![Build Status](https://camo.githubusercontent.com/37a916a52c057bd2a8bcbeaaa8723292a32b6bf648cc179e57d812fdb1d89f3f/68747470733a2f2f7472617669732d63692e6f72672f6d6f74696f6e2d7765622d70726f64756374696f6e2f796969322d6c616e67756167652d70726f76696465722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/motion-web-production/yii2-language-provider)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/1280bb2a526b0464a6c87e6e6061aac394310097c435d2d57b6c981ccce41b42/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d6f74696f6e2d7765622d70726f64756374696f6e2f796969322d6c616e67756167652d70726f76696465722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/motion-web-production/yii2-language-provider/?branch=master)

From the box you can use:

- [Config language provider](#config-language-provider)
- [Database language provider](#database-language-provider)

If you want to create your implementation of language provider you should implement interface `motion\i18n\LanguageProviderInterface`.

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

[](#installation)

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

Either run

```
$ composer require motion/yii2-language-provider

```

or add

```
"motion/yii2-language-provider": "~2.1"

```

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

Usage
-----

[](#usage)

### Config language provider

[](#config-language-provider)

OptionDescriptionTypeDefaultlanguagesShould contains list of application languages.array`[]`defaultLanguageShould contains default application language.array`[]`#### Example

[](#example)

```
$config = [
    'languages' => [
        [
            'label' => 'English',
            'locale' => 'en',
        ],
        [
            'label' => 'Ukrainian',
            'locale' => 'uk',
        ],
        [
            'label' => 'Russian',
            'locale' => 'ru',
        ],
    ],
    'defaultLanguage' => [
        'label' => 'English',
        'locale' => 'en',
    ],
];

$provider = new \motion\i18n\ConfigLanguageProvider($config);
$provider->getLanguages(); // returns list of languages
$provider->getDefaultLanguage(); // returns default language
$provider->getLanguageLabel('en'); // returns language label by locale (`English`)
```

### Database language provider

[](#database-language-provider)

OptionDescriptionTypeDefaultdbDatabase connection instance.string, array, `\yii\db\Connection``db`tableNameName of language entity in database.string`language`localeFieldName of locale field in language entity.string`locale`labelFieldName of label field in language entity.string`label`defaultFieldName of field in table with default language flag.string`is_default`#### Example

[](#example-1)

```
$config = [
    'db' => 'secondDb',
    'labelField' => 'title',
];

$provider = new \motion\i18n\DbLanguageProvider($config);
$provider->getLanguages(); // returns list of languages
$provider->getDefaultLanguage(); // returns default language
$provider->getLanguageLabel('uk'); // returns language label by locale
```

Tests
-----

[](#tests)

You can run tests with composer command

```
$ composer test

```

or using following command

```
$ codecept build && codecept run

```

Licence
-------

[](#licence)

[![License](https://camo.githubusercontent.com/0733ca30b1e9ab00e4e9bb12d678c3d2c910d79ea0f19b5ac393fcb588d7114c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6d6f74696f6e2d7765622d70726f64756374696f6e2f796969322d6c616e67756167652d70726f76696465722e737667)](LICENSE)

This project is released under the terms of the BSD-3-Clause [license](LICENSE).

Copyright (c) 2017-2018, Motion Web Production

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance12

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity65

Established project with proven stability

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

Total

3

Last Release

3041d ago

Major Versions

1.0.0 → 2.0.02017-12-25

### Community

Maintainers

![](https://www.gravatar.com/avatar/9c7243572d974ba9ce049b0a67fd95cf547fd62ea531784d2dfbcc1fbee16806?d=identicon)[greeflas](/maintainers/greeflas)

---

Top Contributors

[![greeflas](https://avatars.githubusercontent.com/u/17636915?v=4)](https://github.com/greeflas "greeflas (28 commits)")

---

Tags

i18nmultilanguageyii2yii2-extensioni18nlanguageprovideryii2

###  Code Quality

TestsCodeception

### Embed Badge

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

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

###  Alternatives

[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)
