File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change 1212use yii \helpers \Url ;
1313use yii \helpers \ArrayHelper ;
1414use yii \base \InvalidConfigException ;
15+ use yii ;
1516
1617/**
1718 * @link https://select2.github.io
@@ -136,8 +137,20 @@ public function run()
136137 public function registerAssets ()
137138 {
138139 $ view = $ this ->getView ();
139-
140- Select2Asset::register ($ view );
140+ $ bandle = Select2Asset::register ($ view );
141+ if ($ this ->language !== false ) {
142+ $ langs [0 ] = $ this ->language ? $ this ->language : \Yii::$ app ->language ;
143+ if (strpos ($ langs [0 ], '- ' ) > 0 ) {
144+ $ langs [1 ] = explode ('- ' , $ langs [0 ])[0 ];
145+ }
146+ foreach ($ langs as $ lang ) {
147+ $ langFile = "/js/i18n/ {$ lang }.js " ;
148+ if (file_exists ($ bandle ->sourcePath .$ filename )) {
149+ $ view ->registerJsFile ($ bandle ->baseUrl .$ langFile , ['depends ' => Select2Asset::className ()]);
150+ break ;
151+ }
152+ }
153+ }
141154 if ($ this ->bootstrap ) {
142155 Select2BootstrapAsset::register ($ view );
143156 }
You can’t perform that action at this time.
0 commit comments