private function _getUrls()
 {
     $route = \Yii::$app->controller->route;
     $urls = [];
     foreach (Language::enabled() as $locale) {
         $urls[$locale] = ["/{$route}", 'language' => $locale];
     }
     return $urls;
 }
 public function init()
 {
     \Yii::$app->language = Language::getDefault();
     $this->languages = Language::enabled();
     parent::init();
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getLanguage()
 {
     return $this->hasOne(Language::className(), ['code' => 'language_id']);
 }
 public function run($id)
 {
     Language::disable($id);
     exit;
 }
Example #5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getLanguages()
 {
     return $this->hasMany(Language::className(), ['code' => 'language_id'])->viaTable('city_translation', ['city_id' => 'id']);
 }
 /**
  * 
  * Disable a language by removing locale from database storage
  * 
  * @param string $locale - Locale to be enabled
  * @return int - status code
  */
 public function actionDisable($locale)
 {
     Language::disable($locale);
     return 0;
 }
Example #7
0
 /**
  * 
  * @return string(2)|NULL
  */
 public static function getDefault()
 {
     $model = Language::findOne(['is_default' => TRUE]);
     if (isset($model)) {
         return $model->id;
     }
     return NULL;
 }
 public function run($id)
 {
     Language::setDefault($id);
     exit;
 }