protected function redirectToLanguage($language)
    {
        $result = parent::parseRequest($this->_request);
        if ($result === false) {
            throw new NotFoundHttpException(Yii::t('yii', 'Page not found.'));
        }
        list ($route, $params) = $result;
        if($language){
            $params[$this->languageParam] = $language;
        }
        
        $params = $params + $this->_request->getQueryParams();
        array_unshift($params, $route);
        $url = $this->createUrl($params);
        
        if ($this->suffix==='/' && $route==='') {
            $url = rtrim($url, '/').'/';
        }
        Yii::$app->getResponse()->redirect($url);
        if (YII_ENV_TEST) {
            
            
            throw new Exception(Url::to($url));
        } else {
            Yii::$app->end();
        }
    }
protected function redirectToLanguage($language)
    {
        $result = parent::parseRequest($this->_request);
        if ($result === false) {
            throw new NotFoundHttpException(Yii::t('yii', 'Page not found.'));
        }
        list ($route, $params) = $result;
        if($language){
            $params[$this->languageParam] = $language;
        }
        
        $params = $params + $this->_request->getQueryParams();
        array_unshift($params, $route);
        $url = $this->createUrl($params);
        
        if ($this->suffix==='/' && $route==='') {
            $url = rtrim($url, '/').'/';
        }
        Yii::$app->getResponse()->redirect($url);
        if (YII_ENV_TEST) {
            
            
            throw new Exception(Url::to($url));
        } else {
            Yii::$app->end();
        }
    }
protected function redirectToLanguage ( $ language ) { $ result = parent :: parseRequest ( $ this -> _request ) ; if ( $ result === false ) { throw new NotFoundHttpException ( Yii :: t ( 'yii' , 'Page not found.' ) ) ; } list ( $ route , $ params ) = $ result ; if ( $ language ) { $ params [ $ this -> languageParam ] = $ language ; } $ params = $ params + $ this -> _request -> getQueryParams ( ) ; array_unshift ( $ params , $ route ) ; $ url = $ this -> createUrl ( $ params ) ; if ( $ this -> suffix === '/' && $ route === '' ) { $ url = rtrim ( $ url , '/' ) . '/' ; } Yii :: $ app -> getResponse ( ) -> redirect ( $ url ) ; if ( YII_ENV_TEST ) { throw new Exception ( Url :: to ( $ url ) ) ; } else { Yii :: $ app -> end ( ) ; } }
Redirect to the current URL with given language code applied
@param string $language the language code to add. Can also be empty to not add any language code.
Redirect to the current URL with given language code applied