2017 © Pedro Peláez
 

yii2-extension yii2-multilang

Multilanguage tools package

image

xz1mefx/yii2-multilang

Multilanguage tools package

  • Friday, April 7, 2017
  • by xZ1mEFx
  • Repository
  • 3 Watchers
  • 3 Stars
  • 72 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 10 Versions
  • 3 % Grown

The README.md

Multilanguage tools package for yii2

Latest Version on Packagist Software License Total Downloads, (*1)

The extension is a package of tools to implement multilanguage in Yii2 project: - Automatically redirects the user to the URL selected (automatically or manually) language and remembers the user selected language - Automatically collect all new translates into DB - Has a widget to set a correct hreflang attributes - Provides a CRUD actions for edit the list of languages and the interface translations - Has a widget to create language selector (for adminlte theme) - Has a @weblang\ alias with current language, (*2)

Installation

  1. The preferred way to install this extension is through composer, run:, (*3)

    php composer.phar require --prefer-dist xz1mefx/yii2-multilang "~1"
    
  2. Add new multilangCache component to common config file:, (*4)

    'multilangCache' => [
        'class' => \xz1mefx\multilang\caching\MultilangCache::className(),
    ],
    
  3. Execute migration:, (*5)

    php yii migrate --migrationPath=@vendor/xz1mefx/yii2-multilang/migrations --interactive=0
    

    or you can create new migration and extend it, example:, (*6)

    require(Yii::getAlias('@vendor/xz1mefx/yii2-multilang/migrations/m161210_131014_multilang_init.php'));
    
    /**
    * Class m161221_135351_multilang_init
    */
    class m161221_135351_multilang_init extends m161210_131014_multilang_init
    {
    }
    
  4. Override components in common config file:, (*7)

    '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(),
    ],
    
  5. [not necessary] If you use iiifx-production/yii2-autocomplete-helper you need to run:, (*8)

  6. Override some components in console config file:, (*9)

    'request' => [ // override common config
        'class' => 'yii\console\Request',
    ],
    'urlManager' => [], // override common config
    'i18n' => [], // override common config
    
  7. Add HrefLangs widget to page <head></head> section in layout(s):, (*10)

    <?= \xz1mefx\multilang\widgets\HrefLangs::widget() ?>
    
  8. Add LanguageController (or another) with next code:, (*11)

    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,
            ],
        ];
    }
    

    , where you can change action theme (THEME_BOOTSTRAP - by default or THEME_ADMINLTE) , view path and access to controls in index action., (*12)

    This controller will control system languages., (*13)

  9. Add TranslationController (or another) with next code:, (*14)

    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,
            ],
        ];
    }
    

    , where you can change action theme (THEME_BOOTSTRAP - by default or THEME_ADMINLTE) , view path and access to controls in index action., (*15)

    This controller will control interface translations., (*16)

  10. [not necessary, only for adminlte theme] Add language selector widget into header ul.nav:, (*17)

    <?= \xz1mefx\multilang\widgets\adminlte\HeaderDropDownLangSelector::widget() ?>
    

AdminLTE theme you can found in xz1mefx/yii2-adminlte package., (*18)

The Versions

07/04 2017

dev-master

9999999-dev

Multilanguage tools package

  Sources   Download

MIT

The Requires

 

by Vitalii Zagorodniuk

language yii2 locale lang xz1mefx

13/01 2017

v1.2.3

1.2.3.0

Multilanguage tools package

  Sources   Download

MIT

The Requires

 

by Vitalii Zagorodniuk

language yii2 locale lang xz1mefx

11/01 2017

v1.2.2

1.2.2.0

Multilanguage tools package

  Sources   Download

MIT

The Requires

 

by Vitalii Zagorodniuk

language yii2 locale lang xz1mefx

25/12 2016

v1.2.1

1.2.1.0

Multilanguage tools package

  Sources   Download

MIT

The Requires

 

by Vitalii Zagorodniuk

language yii2 locale lang xz1mefx

23/12 2016

v1.2.0

1.2.0.0

Multilanguage tools package

  Sources   Download

MIT

The Requires

 

by Vitalii Zagorodniuk

language yii2 locale lang xz1mefx

23/12 2016

v1.1.3.1

1.1.3.1

Multilanguage tools package

  Sources   Download

MIT

The Requires

 

by Vitalii Zagorodniuk

language yii2 locale lang xz1mefx

22/12 2016

v1.1.3

1.1.3.0

Multilanguage tools package

  Sources   Download

MIT

The Requires

 

by Vitalii Zagorodniuk

language yii2 locale lang xz1mefx

21/12 2016

v1.1.2

1.1.2.0

Multilanguage tools package

  Sources   Download

MIT

The Requires

 

by Vitalii Zagorodniuk

language yii2 locale lang xz1mefx

13/12 2016

v1.0.0

1.0.0.0

Multilanguage tools package

  Sources   Download

MIT

The Requires

 

by Vitalii Zagorodniuk

language yii2 locale lang xz1mefx

10/12 2016

v1.0.0-rc

1.0.0.0-RC

Multilanguage tools package

  Sources   Download

MIT

The Requires

 

by Vitalii Zagorodniuk

language yii2 locale lang xz1mefx