2017 © Pedro Peláez
 

yii2-extension yii2-language-provider

This package provides interface for language provider for Yii2 Framework

image

motion/yii2-language-provider

This package provides interface for language provider for Yii2 Framework

  • Sunday, March 18, 2018
  • by greeflas
  • Repository
  • 1 Watchers
  • 4 Stars
  • 1,933 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 2 Open issues
  • 4 Versions
  • 120 % Grown

The README.md

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 extension., (*1)

Latest Stable Version Monthly Downloads Total Downloads Build Status Scrutinizer Code Quality, (*2)

From the box you can use:, (*3)

If you want to create your implementation of language provider you should implement interface motion\i18n\LanguageProviderInterface., (*4)

Installation

The preferred way to install this extension is through composer., (*5)

Either run, (*6)

$ composer require motion/yii2-language-provider

or add, (*7)

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

to the require section of your composer.json., (*8)

Usage

Config language provider

Option Description Type Default
languages Should contains list of application languages. array []
defaultLanguage Should contains default application language. array []

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

Option Description Type Default
db Database connection instance. string, array, \yii\db\Connection db
tableName Name of language entity in database. string language
localeField Name of locale field in language entity. string locale
labelField Name of label field in language entity. string label
defaultField Name of field in table with default language flag. string is_default

Example

$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

You can run tests with composer command, (*9)

$ composer test

or using following command, (*10)

$ codecept build && codecept run

Licence

License, (*11)

This project is released under the terms of the BSD-3-Clause license., (*12)

Copyright (c) 2017-2018, Motion Web Production, (*13)

The Versions

18/03 2018

dev-master

9999999-dev

This package provides interface for language provider for Yii2 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Vladimir Kuprienko

language yii2 i18n provider

19/01 2018

2.1.0

2.1.0.0

Language providers kit for modules based on Yii2 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Vladimir Kuprienko

language yii2 i18n provider

25/12 2017

2.0.0

2.0.0.0

Language providers kit for modules based on Yii2 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Vladimir Kuprienko

language yii2 i18n provider

02/11 2017

1.0.0

1.0.0.0

Language providers kit for modules based on Yii2 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Vladimir Kuprienko

language yii2 i18n provider