Commit 3cf9e8f8 by Alexander Makarov

Fixes #2572: Corrected LanguageAsset example

parent dba03031
......@@ -81,18 +81,26 @@ following way:
```php
class LanguageAsset extends AssetBundle
{
public $sourcePath = '@app/assets/language';
public $js = [
];
public function init()
{
$this->js[] = 'language-' . Yii::$app->language . '.js';
parent::init();
}
public $language;
public $sourcePath = '@app/assets/language';
public $js = [
];
public function registerAssetFiles($view)
{
$language = $this->language ? $this->language : Yii::$app->language;
$this->js[] = 'language-' . $language . '.js';
parent::init();
}
}
```
In order to set language use the following code when registering an asset bundle in a view:
```php
LanguageAsset::register($this)->language = $language;
```
Registering asset bundle
------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment