public function detectLocaleFromHttpHeader($acceptLanguageHeader)
    {
        $acceptableLanguages = I18n\Utility::parseAcceptLanguageHeader($acceptLanguageHeader);

        if ($acceptableLanguages === false) {
            return $this->localizationService->getConfiguration()->getDefaultLocale();
        }

        foreach ($acceptableLanguages as $languageIdentifier) {
            if ($languageIdentifier === '*') {
                return $this->localizationService->getConfiguration()->getDefaultLocale();
            }

            try {
                $locale = new Locale($languageIdentifier);
            } catch (Exception\InvalidLocaleIdentifierException $exception) {
                continue;
            }

            $bestMatchingLocale = $this->localeCollection->findBestMatchingLocale($locale);

            if ($bestMatchingLocale !== null) {
                return $bestMatchingLocale;
            }
        }

        return $this->localizationService->getConfiguration()->getDefaultLocale();
    }