Download the PHP package user1007017/yii2-language-picker without Composer
On this page you can find all versions of the php package user1007017/yii2-language-picker. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download user1007017/yii2-language-picker
More information about user1007017/yii2-language-picker
Files in user1007017/yii2-language-picker
Package yii2-language-picker
Short Description Yii2 Language Picker Widget
License BSD-3-Clause
Informations about the package yii2-language-picker
Yii2 Language Picker
Yii2 Language Picker Widget
Introduction
The widget provides an easy to use language selector which makes it possible to change the language of our website easily. The language change can take place synchronously or asynchronously (through Ajax). The default method is asynchronous (through an Ajax call), however when this method fails for any reason (e.g. JavaScript is blocked on the client side) the new language will actualise synchronously through an automatic page reload.
The language switcher is fully customisable. However, the pre-defined options provide a dropdown list (DropDownList), and a link-based list (ButtonList). Both versions can display the name of the chosen language and the corresponding flag (icon).
Installation
The preferred way to install this extension is through composer.
Either run
or add
to the require section of your composer.json
file.
Config:
Identifier of the language element. e.g.: en, en-US
Minimal configuration (icons only)
Minimal configuration (icons and text)
Full configuration (icons only)
Yii2-translate-manager integration
Minimal configuration (icons only)
Full configuration (icons and text)
IMPORTANT
To use the widget, the value of the enablePrettyUrl property in the urlManager configuration must be true, and the value of showScriptName false.
example:
Using of urlManager.
Usage
Displaying language selector
Displaying pre-defined languate picker buttons (icons and text or icons only):
Displaying pre-defined languate picker dropdown list (icons and text or icons only):
Customising the language picker:
Other Example hiding active Language
NavBar::begin([
'brandLabel' => Html::img('@web/css/images/logo.png', ['class' => 'img-responsive','alt' => Yii::$app->name]),
'brandUrl' => Yii::$app->homeUrl,
'options' => [
'class' => 'navbar navbar-default navbar-fixed-top',
],
]);
$aNavOptionsTop = [
'options' => ['class' => 'navbar-nav navbar-left'],
// 'options' => ['class' => 'nav nav-justified '],
'items' => $items
];
echo Nav::widget($aNavOptionsTop);
//---------------------------LANGUAGE PICKER ---------------------------------------------
echo \user1007017\languagepicker\widgets\LanguagePicker::widget([
'skin' => \user1007017\languagepicker\widgets\LanguagePicker::SKIN_BUTTON,
'size' => \user1007017\languagepicker\widgets\LanguagePicker::SIZE_SMALL,
'itemTemplate' => '<a href="{link}" title="{language}"> {name}</a>',
//hide active language (display:none):
'activeItemTemplate' => '<a style="display:none" href="{link}" title="{language}" class="active"></a>',
// parentTemplate without {size} !!!:
'parentTemplate' => '<ul style="list-style: none;" class="navbar-nav navbar-right nav"><li>{items}</li></ul>',
]);
//-------------------------------------------------------------------------------
NavBar::end();