Class lajax\languagepicker\widgets\LanguagePicker

Inheritancelajax\languagepicker\widgets\LanguagePicker » yii\base\Widget
Available since version1.0

Language Picker widget.

Examples: Pre-defined button list:

\lajax\languagepicker\widgets\LanguagePicker::widget([
     'skin' => \lajax\languagepicker\widgets\LanguagePicker::SKIN_BUTTON,
     'size' => \lajax\languagepicker\widgets\LanguagePicker::SIZE_SMALL
]);

Pre-defined DropDown list:

 \lajax\languagepicker\widgets\LanguagePicker::widget([
     'skin' => \lajax\languagepicker\widgets\LanguagePicker::SKIN_DROPDOWN,
     'size' => \lajax\languagepicker\widgets\LanguagePicker::SIZE_LARGE
]);

Defining your own template:

 \lajax\languagepicker\widgets\LanguagePicker::widget([
     'itemTemplate' => '<li><a href="{link}"><i class="{language}" title="{language}"></i> {name}</a></li>',
     'activeItemTemplate' => '<a href="{link}" title="{language}"><i class="{language}"></i> {name}</a>',
     'parentTemplate' => '<div class="language-picker dropdown-list {size}"><div>{activeItem}<ul>{items}</ul></div></div>',

     'languageAsset' => 'lajax\languagepicker\bundles\LanguageLargeIconsAsset',      // StyleSheets
     'languagePluginAsset' => 'lajax\languagepicker\bundles\LanguagePluginAsset',    // JavasSripts
]);

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$activeItemTemplate string The structure of the active language element. lajax\languagepicker\widgets\LanguagePicker
$encodeLabels boolean Whether to HTML-encode the link labels. lajax\languagepicker\widgets\LanguagePicker
$itemTemplate string The structure of one entry in the list of language elements. lajax\languagepicker\widgets\LanguagePicker
$languageAsset string Adding StyleSheet and its dependencies. lajax\languagepicker\widgets\LanguagePicker
$languagePluginAsset string Adding JavaScript and its dependencies. lajax\languagepicker\widgets\LanguagePicker
$languages array List of available languages. lajax\languagepicker\widgets\LanguagePicker
$parentTemplate string The structure of the parent template. lajax\languagepicker\widgets\LanguagePicker
$size string Size of the icons. lajax\languagepicker\widgets\LanguagePicker
$skin string ID of pre-defined skin (optional). lajax\languagepicker\widgets\LanguagePicker

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
renderItem() Rendering languege element. lajax\languagepicker\widgets\LanguagePicker

Constants

Hide inherited constants

ConstantValueDescriptionDefined By
SIZE_LARGE 'large' Size of pre-defined skins (large). lajax\languagepicker\widgets\LanguagePicker
SIZE_SMALL 'small' Size of pre-defined skins (small). lajax\languagepicker\widgets\LanguagePicker
SKIN_BUTTON 'button' Type of pre-defined skins (button list). lajax\languagepicker\widgets\LanguagePicker
SKIN_DROPDOWN 'dropdown' Type of pre-defined skins (drop down list). lajax\languagepicker\widgets\LanguagePicker

Property Details

$activeItemTemplate public property

The structure of the active language element.

$encodeLabels public property

Whether to HTML-encode the link labels.

$itemTemplate public property

The structure of one entry in the list of language elements.

$languageAsset public property

Adding StyleSheet and its dependencies.

$languagePluginAsset public property
string $languagePluginAsset 'lajax\languagepicker\bundles\LanguagePluginAsset'

Adding JavaScript and its dependencies. Changing languages is done through Ajax by default. If you do not wish to use Ajax, set value to null.

$languages public property

List of available languages. Formats supported in the pre-defined skins:

 ['en', 'de', 'es']
 ['en' => 'English', 'de' => 'Deutsch', 'fr' => 'Français']
 ['en-US', 'de-DE', 'fr-FR']
 ['en-US' => 'English', 'de-DE' => 'Deutsch', 'fr-FR' => 'Français']
$parentTemplate public property

The structure of the parent template.

$size public property
string $size null

Size of the icons.

$skin public property
string $skin null

ID of pre-defined skin (optional).

Method Details

init() public method

void init( )
renderItem() protected method

Rendering languege element.

string renderItem$language$name$template )
$language string

The property of a given language.

$name string

The property of a language name.

$template string

The basic structure of a language element of the displayed language picker Elements to replace: "{link}" URL to call when changing language. "{name}" name corresponding to a language element, e.g.: English "{language}" unique identifier of the language element. e.g.: en, en-US

return string

The rendered result

run() public method

void run( )
widget() public method

void widget$config = [] )
$config