2017 © Pedro Peláez
 

yii2-extension yii2-language-url-manager

Parses and creates URLs containing languages for the Yii framework 2.0

image

cetver/yii2-language-url-manager

Parses and creates URLs containing languages for the Yii framework 2.0

  • Sunday, March 4, 2018
  • by cetver
  • Repository
  • 1 Watchers
  • 3 Stars
  • 260 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 4 Versions
  • 56 % Grown

The README.md

Language Url Manager

Build Status Coverage Status, (*1)

Parses and creates URLs containing languages, (*2)

Installation

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

Either run, (*4)

composer require --prefer-dist cetver/yii2-language-url-manager

or add, (*5)

"cetver/yii2-language-url-manager": "^1.0"

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

Usage

Update the web-application configuration file, (*7)

return [
    'components' => [
        'urlManager' => [
            'class' => 'cetver\LanguageUrlManager\UrlManager',
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            /*
             * The list of available languages.
             */
            'languages' => ['en', 'ru'],
            /*
            or
            'languages' => function () {
                return \app\models\Language::find()->select('code')->column();
            },
            */
            /*
             * - true: processes the URL like "en.example.com"
             * - false: processes the URL like "example.com/en"
             * NOTE: If this property set to true, the domain containing a language, must be the first on the left side,
             * for example:
             * - en.it.example.com - is valid
             * - it.en.example.com - is invalid
             */
            'existsLanguageSubdomain' => false,
            /*
             * The regular expression patterns list, applied to path info, if there are matches, the request,
             * containing a language, will not be processed.
             * For performance reasons, the blacklist does not applied for URL creation (Take a look at an example).
             * @see \yii\web\Request::getPathInfo()
             * An example:
             * ```php
             * [
             *     '/^api.*$/'
             * ]
             * ```
             * - Requesting the blacklisted URL
             *   - $existsLanguageSubdomain = true
             *     - en.example.com/api (404 Not Found)
             *     - en.example.com/api/create (404 Not Found)
             *   - $existsLanguageSubdomain = false
             *     - example.com/en/api (404 Not Found)
             *     - example.com/en/api/create (404 Not Found)
             * - Creating the blacklisted URL
             *   - echo \yii\helpers\Html::a('API', ['api/index', Yii::$app->urlManager->queryParam => null]);
             */
            'blacklist' => [],
            /*
             * The query parameter name that contains a language.
             */
            'queryParam' => 'language'
        ],
    ]
];

Tests

Run the following commands, (*8)

composer create-project --prefer-source cetver/yii2-language-url-manager
cd yii2-language-url-manager
vendor/bin/codecept run unit

For I18N support, take a look at

The Versions

04/03 2018

dev-master

9999999-dev

Parses and creates URLs containing languages for the Yii framework 2.0

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Alexandr Cetvertacov

language url domain extension yii2 request locale i18n internationalization parse

04/03 2018

1.0.2

1.0.2.0

Parses and creates URLs containing languages for the Yii framework 2.0

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Alexandr Cetvertacov

language url domain extension yii2 request locale i18n internationalization parse

08/01 2018

1.0.1

1.0.1.0

Parses and creates URLs containing languages for the Yii framework 2.0

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Alexandr Cetvertacov

language url domain extension yii2 request locale i18n internationalization parse

19/07 2017

1.0.0

1.0.0.0

Parses and creates URLs containing languages for the Yii framework 2.0

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Alexandr Cetvertacov

language url domain extension yii2 request locale i18n internationalization parse