original_string: public function beforeAction($event)
      {
          if (!Yii::$app->errorHandler->exception && count($this->languages) > 1) {
  
              // Set language by GET request, session or cookie
              if ($language = Yii::$app->getRequest()->get('language')) {
  
                  Yii::$app->language = $this->getLanguageCode($language);
                  Yii::$app->session->set('language', Yii::$app->language);
                  Yii::$app->response->cookies->add(new \yii\web\Cookie([
                      'name' => 'language',
                      'value' => Yii::$app->session->get('language'),
                      'expire' => time() + 31536000 // one year
                  ]));
              } elseif ($language = Yii::$app->session->get('language')) {
  
                  Yii::$app->language = $this->getLanguageCode($language);
              } elseif (isset(Yii::$app->request->cookies['language'])) {
  
                  $language = Yii::$app->request->cookies['language']->value;
                  Yii::$app->language = $this->getLanguageCode($language);
              }
  
              Yii::$app->formatter->locale = Yii::$app->language;
          }
  
          return $event->isValid;
      }
code: public function beforeAction($event)
      {
          if (!Yii::$app->errorHandler->exception && count($this->languages) > 1) {
  
              // Set language by GET request, session or cookie
              if ($language = Yii::$app->getRequest()->get('language')) {
  
                  Yii::$app->language = $this->getLanguageCode($language);
                  Yii::$app->session->set('language', Yii::$app->language);
                  Yii::$app->response->cookies->add(new \yii\web\Cookie([
                      'name' => 'language',
                      'value' => Yii::$app->session->get('language'),
                      'expire' => time() + 31536000 // one year
                  ]));
              } elseif ($language = Yii::$app->session->get('language')) {
  
                  Yii::$app->language = $this->getLanguageCode($language);
              } elseif (isset(Yii::$app->request->cookies['language'])) {
  
                  $language = Yii::$app->request->cookies['language']->value;
                  Yii::$app->language = $this->getLanguageCode($language);
              }
  
              Yii::$app->formatter->locale = Yii::$app->language;
          }
  
          return $event->isValid;
      }
code_tokens: public function beforeAction ( $ event ) { if ( ! Yii :: $ app -> errorHandler -> exception && count ( $ this -> languages ) > 1 ) { // Set language by GET request, session or cookie if ( $ language = Yii :: $ app -> getRequest ( ) -> get ( 'language' ) ) { Yii :: $ app -> language = $ this -> getLanguageCode ( $ language ) ; Yii :: $ app -> session -> set ( 'language' , Yii :: $ app -> language ) ; Yii :: $ app -> response -> cookies -> add ( new \ yii \ web \ Cookie ( [ 'name' => 'language' , 'value' => Yii :: $ app -> session -> get ( 'language' ) , 'expire' => time ( ) + 31536000 // one year ] ) ) ; } elseif ( $ language = Yii :: $ app -> session -> get ( 'language' ) ) { Yii :: $ app -> language = $ this -> getLanguageCode ( $ language ) ; } elseif ( isset ( Yii :: $ app -> request -> cookies [ 'language' ] ) ) { $ language = Yii :: $ app -> request -> cookies [ 'language' ] -> value ; Yii :: $ app -> language = $ this -> getLanguageCode ( $ language ) ; } Yii :: $ app -> formatter -> locale = Yii :: $ app -> language ; } return $ event -> isValid ; }
docstring: Tracks language parameter for multilingual controllers.
  
  @param ActionEvent $event
  @return bool
  @throws MethodNotAllowedHttpException|InvalidConfigException when the request method is not allowed.
docstring_tokens: Tracks language parameter for multilingual controllers .