Download the PHP package sjaakp/yii2-polyglot without Composer
On this page you can find all versions of the php package sjaakp/yii2-polyglot. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sjaakp/yii2-polyglot
More information about sjaakp/yii2-polyglot
Files in sjaakp/yii2-polyglot
Package yii2-polyglot
Short Description Ultralight language chooser for the Yii 2.0 framework
License MIT
Informations about the package yii2-polyglot
yii2-polyglot
Ultralight language chooser for Yii2
yii2-polyglot is an application component plus two widgets with flag buttons to choose the application language. It can be used in the Yii 2.0 PHP Framework.
yii2-polyglot was developed as an alternative to other language choosers, which in my opinion are often overly complex.
yii2-polyglot lets the user choose her favourite language by clicking on a flag button. The chosen language becomes the site's main language and is stored in a cookie.
A demonstration of Yii2-polyglot is here.
Installation
Install yii2-polyglot in the usual way with Composer.
Add the following to the require section of your composer.json
file:
"sjaakp/yii2-polyglot": "*"
or run:
composer require sjaakp/yii2-polyglot
You can manually install yii2-polyglot by downloading the source in ZIP-format.
Using yii2-polyglot
First of all, Polyglot should be installed as an application component.
This is done
in the main configuration file, usually called web.php
or main.php
in the config
directory. Add the following to the configuration array:
...
<?= PolyglotButtons::widget() ?>;
...
Or:
...
<?= PolyglotDropdown::widget() ?>;
...
As you will most likely want to have the Polyglot widget on all of your pages, the preferable place for a widget would be the layout viewfile (or one of the layout viewfiles).
Widget options
PolyglotButtons and PolyglotDropdown have the following options:
- options
array
HTML options for the surrounding element. Default:[]
. - buttonOptions
array
HTML options for the individual flag buttons. Default:[]
. - toggleOptions
array
(PolyglotDropdown only) HTML options for the toggle button. Default:['class' => 'nav-link']
.