2017 © Pedro Peláez
 

yii2-extension yii2-langs

Langs

image

jakharbek/yii2-langs

Langs

  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 120 % Grown

The README.md

Langs

Langs, (*1)

Installation

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

Either run, (*3)

php composer.phar require --prefer-dist jakharbek/yii2-langs "*"

or add, (*4)

"jakharbek/yii2-langs": "*"

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

Usage

execute the migration here, (*6)

yii migrate --migrationPath=@vendor/jakharbek/yii2-langs/src/migrations

in backend part add this code, (*7)

    'on beforeAction' => function () {
        jakharbek\langs\components\Lang::onRequestHandler();
    },

Once the extension is installed, simply use it in your code by :, (*8)

You need to create in your model (table in the database) for translation for the field [[lang]] and the field [[lang_hash]] then add the behavior to the model ActiveRecord jakharbek\langs\components\ModelBehavior, (*9)

example, (*10)

```, (*11)

'lang' => [ 'class' => ModelBehavior::className(), ],, (*12)

```, (*13)

View, (*14)


To use on the page you had a translation you need to lead   widget \jakharbek\langs\widgets\LangsWidgets::widget();   this widget has two modes of operation: single and multiple.   When you specify the model property to be translated:, (*15)

\jakharbek\langs\widgets\LangsWidgets::widget(['model_db' => $model,'create_url' => '/url/to/create/']);

  then it is in solitary if you do not specify model_db then it will work   in multiple modes, (*16)

If you need to take into account the current language in the requests, then you can use the behavior php \jakharbek\langs\components\QueryBehavior after applying the behavior you can now use it as an example: php YourModel::find()->lang()->..., (*17)

The Versions

27/02 2018

dev-master

9999999-dev

Langs

  Sources   Download

MIT

The Requires

 

extension yii2 langs