public function init()
    {
        // parsing needed if urlFormat 'path'
        if (Yii::app() instanceof CWebApplication) {
            Yii::app()->urlManager->parseUrl(Yii::app()->getRequest());
        }

        // 1. get language preference
        $preferred = null;
        if (isset($_GET[self::DATA_KEY])) {
            // use language from URL
            $preferred = $_GET[self::DATA_KEY];
        } elseif ($this->usePreferred) {
            // use preferred browser language as default
            $preferred = Yii::app()->request->preferredLanguage;
        } else {
            $preferred = Yii::app()->language;
        }

        // 2. select language based on available languages and mappings
        $lang = $this->resolveLanguage($preferred);

        if (is_null($lang) && $this->matchShort === true) {
            $preferredShort = substr($preferred, 0, 2);
            $lang           = $this->resolveLanguage($preferredShort);
        }
        // 3. set the language
        if (in_array($lang, $this->languages)) {
            Yii::app()->setLanguage($lang);
        } else {
            // fallback or output error
            if ($this->fallback) {
                // default app language
            } else {
                throw new CHttpException(404, "Language '{$_GET[self::DATA_KEY]}' is not available.");
            }
        }

        if ($this->localizedHomeUrl) {
            $controller         = new CController('P3LangHandlerDummy');
            Yii::app()->homeUrl = $controller->createUrl('/');
        }
    }