public function parseRequest($request)
    {
        if (count($this->availableLanguages) > 0) {
            if (preg_match('/\/(' . implode('|', $this->availableLanguages) . ')(.*)/si', $request->url, $matches)) {
                Yii::$app->language = $matches[1];
            }
        }

        $res = parent::parseRequest($request);
        if (is_array($res)) {
            if (isset($res[1]['language']) && in_array($res[1]['language'], $this->availableLanguages)) {
                Yii::$app->language = $res[1]['language'];
            }
        }
        return $res;
    }