Skip to content

Commit

Permalink
language asset register.
Browse files Browse the repository at this point in the history
  • Loading branch information
mhunesi committed Jul 1, 2020
1 parent 63a842b commit 4ed13b2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Select2Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Select2Asset extends \yii\web\AssetBundle
];

public $js = [
'js/select2.min.js',
'js/select2.full.min.js',
];

public $depends = [
Expand Down
10 changes: 9 additions & 1 deletion Select2Widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ public function registerClientScript()
*/
protected function registerBundle(View $view)
{
Select2Asset::register($view);
$lang = substr(ArrayHelper::getValue($this->clientOptions,'language','en'),0,2);

$this->clientOptions['language'] = $lang;

$assetBundle = Select2Asset::register($view);

$view->registerJsFile($assetBundle->baseUrl . '/js/i18n/'.$lang.'.js',[
'depends' => [Select2Asset::className()]
]);
}
}

0 comments on commit 4ed13b2

Please sign in to comment.