Skip to content

Latest commit

 

History

History
74 lines (62 loc) · 1.84 KB

INSTALL.md

File metadata and controls

74 lines (62 loc) · 1.84 KB

Installing and configuring extensions

  1. Set in Yii2 configuration file:
'language'   => 'en',
'sourceLanguage' => 'en',

language - default locale.

  1. Set in params file all the languages do you needs:
'languages' => [
    [
        'id' => 1,
        'url' => 'en',
        'locale' => 'en',
        'name' => 'English',
        'default' => true,
    ],
    [
        'id' => 2,
        'url' => 'ru',
        'locale' => 'ru',
        'name' => 'Русский',
    ],
],

* Use unique integer ID. ** Default - default language (/en /ru - standard, / - default). Do not set any default language so that the script always redirects to the language subfolder.

  1. Install the extension through composer:
php composer.phar require pjhl/yii2-multilanguage:~0.2

or add this line to the require section of your composer.json file.

"pjhl/yii2-multilanguage": "^0.2"
  1. Update your components:
'components' => [
    'request' => [
        'class' => 'pjhl\multilanguage\components\AdvancedRequest'
    ],
    'urlManager' => [
        'enablePrettyUrl' => true,
        'showScriptName' => false,
        'class' => 'pjhl\multilanguage\components\AdvancedUrlManager',
    ],
],
  1. Add .htaccess or nginx config for pretty url.

Skip this step if you do not want to use pretty url.

  1. Set in Yii2 configuration file:
'on beforeAction' => ['\pjhl\multilanguage\Start', 'run'],

After install

Okay, you have installed the extension. Now you can configure language switching, creating multilingual models and CRUD.