public function beforeAction($action) { if (parent::beforeAction($action)) { if (!in_array(Yii::$app->user->identity->username, Yii::$app->params['admin']) || !$this->checkAccess()) { throw new ForbiddenHttpException(Yii::t('app', 'You are not allowed to access this page.')); } if (!Common::getLanguage()) { preg_match('/^([a-z\\-]+)/i', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $matches); Common::setLanguage($matches[1]); Yii::$app->language = $matches[1]; } else { Yii::$app->language = Common::getLanguage(); } return true; } else { return false; } }
public function actionLocale($language) { Common::setLanguage($language); return $this->redirect(['index']); }