PHP code example of xz1mefx / yii2-multilang

1. Go to this page and download the library: Download xz1mefx/yii2-multilang library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

xz1mefx / yii2-multilang example snippets


    'multilangCache' => [
        'class' => \xz1mefx\multilang\caching\MultilangCache::className(),
    ],
    

      /**
    * Class m161221_135351_multilang_init
    */
    class m161221_135351_multilang_init extends m161210_131014_multilang_init
    {
    }
    

    'urlManager' => [
        'class' => \xz1mefx\multilang\web\UrlManager::className(),
    ],
    'request' => [
        'class' => \xz1mefx\multilang\web\Request::className(),
    ],
    'i18n' => [
        'class' => \xz1mefx\multilang\i18n\I18N::className(),
    ],
    'lang' => [
        'class' => \xz1mefx\multilang\components\Lang::className(),
    ],
    

    'request' => [ // override common config
        'class' => 'yii\console\Request',
    ],
    'urlManager' => [], // override common config
    'i18n' => [], // override common config
    

    <?= \xz1mefx\multilang\widgets\HrefLangs::widget() 

    use xz1mefx\multilang\actions\language\IndexAction;
    use xz1mefx\multilang\actions\language\CreateAction;
    use xz1mefx\multilang\actions\language\UpdateAction;
    use xz1mefx\multilang\actions\language\DeleteAction;
    
    ...
    
    /**
     * @inheritdoc
     */
    public function actions()
    {
        return [
            'index' => [
                'class' => IndexAction::className(),
    //          'theme' => IndexAction::THEME_ADMINLTE,
    //          'canAdd' => false,
    //          'canUpdate' => false,
    //          'canDelete' => false,
            ],
            'create' => [
                'class' => CreateAction::className(),
    //          'theme' => CreateAction::THEME_ADMINLTE,
            ],
            'update' => [
                'class' => UpdateAction::className(),
    //           'theme' => UpdateAction::THEME_ADMINLTE,
            ],
            'delete' => [
                'class' => DeleteAction::className(),
    //           'theme' => DeleteAction::THEME_ADMINLTE,
            ],
        ];
    }
    

    use xz1mefx\multilang\actions\translation\IndexAction;
    use xz1mefx\multilang\actions\translation\UpdateAction;
    
    ...
    
    /**
     * @inheritdoc
     */
    public function actions()
    {
        return [
            'index' => [
                'class' => IndexAction::className(),
    //          'theme' => IndexAction::THEME_ADMINLTE,
    //          'canUpdate' => false,
            ],
            'update' => [
                'class' => UpdateAction::className(),
    //          'theme' => UpdateAction::THEME_ADMINLTE,
            ],
        ];
    }
    

    <?= \xz1mefx\multilang\widgets\adminlte\HeaderDropDownLangSelector::widget() 
bash
    php yii migrate --migrationPath=@vendor/xz1mefx/yii2-multilang/migrations --interactive=0