pheme/yii2-i18n-url Internationalize your urls

i18nurlmanager

Yii2 i18n URL Manager

Internationalize your urls

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist pheme/yii2-i18n-url "dev-master"

or add

"pheme/yii2-i18n-url": "dev-master"

to the require section of your composer.json file.

Usage

In your configuration file, add or replace your UrlManager component:

'components' => [
    'urlManager' => [
        'class' => 'pheme\i18n\I18nUrlManager',
        //'displaySourceLanguage' => true,
        //'rewriteBaseUrl' => true,
        //'languageParam' => 'lang',
        'languages' => ['en', 'gr'],
        'aliases' => [],
        // 'aliases' => ['en' => 'en-US', 'sr' => 'sr-Latn'],
        // The keys will become labels on the language switcher widget
        // 'languages' => ['English' => 'en', 'Ελληνικά' => 'gr']
        'enablePrettyUrl' => true,
        'showScriptName' => false,
        'rules' => [],
    ],
    ...
]

Example of changing the language

<?= Html::a('Ελληνικά', ['site/index', 'lang' => 'gr']); ?>

Example of using the language switcher

<?= pheme\i18n\widgets\LanguageSwitcher::widget(); ?>

Statistics

Downloads
GitHub Stars
GitHub Forks

Releases

No stable releases.

Comments



No stable releases.



MIT license
Stats
14 github stars & 7 github forks
0 downloads in the last day
2 downloads in the last 30 days
4196 total downloads