protected function getLocale(HTTPRequest $request)
    {
        // Check direct request from either routing params, or request (e.g. GET) vars, in that order
        $locale = $this->getParamLocale($request);

        // Check against domain (non-ambiguous locale only)
        if (empty($locale)) {
            $locale = $this->getDomainLocale();
        }

        // Look for persisted locale
        if (empty($locale)) {
            $locale = $this->getPersistLocale($request);
        }

        // Use locale detector (if configured)
        if (empty($locale)) {
            $locale = $this->getDetectedLocale($request);
        }

        // Fallback to default if empty or invalid
        if (empty($locale) || !Locale::getByLocale($locale)) {
            $locale = $this->getDefaultLocale();
        }

        return (string) $locale;
    }