Class lajax\languagepicker\widgets\LanguagePicker
Inheritance | lajax\languagepicker\widgets\LanguagePicker » yii\base\Widget |
---|---|
Available since version | 1.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
Property | Type | Description | Defined 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 |
Public Methods
Method | Description | Defined By |
---|---|---|
init() | lajax\languagepicker\widgets\LanguagePicker | |
run() | lajax\languagepicker\widgets\LanguagePicker | |
widget() | lajax\languagepicker\widgets\LanguagePicker |
Protected Methods
Method | Description | Defined By |
---|---|---|
renderItem() | Rendering languege element. | lajax\languagepicker\widgets\LanguagePicker |
Constants
Constant | Value | Description | Defined 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
The structure of the active language element.
Whether to HTML-encode the link labels.
The structure of one entry in the list of language elements.
Adding StyleSheet and its dependencies.
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.
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']
The structure of the parent template.
Size of the icons.
ID of pre-defined skin (optional).
Method Details
void init( ) |
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 |
---|
void run( ) |
void widget( $config = [] ) | ||
$config |