Parse all HTTP Accept Languages.

@param string $httpAcceptLanguages

@return void
494394
protected function parseHttpAcceptLanguages($httpAcceptLanguages)
    {
        $locales = $this->split($httpAcceptLanguages, ',');

        foreach ($locales as $httpAcceptLanguage) {
            $this->makeLocale($httpAcceptLanguage);
        }

        $this->sortLocales();
    }
556648
private function getMatchesFromAcceptedLanguages()
    {
        $matches = [];

        $acceptLanguages = $this->request->header('Accept-Language');

        if ( ! empty($acceptLanguages)) {
            $acceptLanguages = explode(',', $acceptLanguages);

            $genericMatches = $this->retrieveGenericMatches($acceptLanguages, $matches);

            $matches = array_merge($genericMatches, $matches);
            arsort($matches, SORT_NUMERIC);
        }

        return $matches;
    }
974993
public function getAcceptLanguages(): array
    {
        $ls = [];

        if ($value = $this->getLine('Accept-Language')) {
            if (\strpos($value, ';')) {
                [$value,] = \explode(';', $value, 2);
            }

            $value = \str_replace(' ', '', $value);
            $ls    = \explode(',', $value);
        }

        return $ls;
    }
3999
protected function _parseLanguage(Horde_Imap_Client_Tokenize $data)
    {
        $lang_list = $data->flushIterator();

        if (count($lang_list) === 1) {
            // This is the language that was set.
            $this->_setInit('lang', reset($lang_list));
        } else {
            // These are the languages that are available.
            $this->_setInit('langavail', $lang_list);
        }
    }
1249299
private function extractLanguageCodesFromSolrResult( $solrResults )
    {
        $languages = array();

        if ( isset( $solrResults['response']['docs'] ) )
        {
            foreach ( $solrResults['response']['docs'] as $doc )
            {
                if ( isset( $doc['meta_language_code_ms'] ) )
                {
                    $languages[] = $doc['meta_language_code_ms'];
                }
            }
        }

        return $languages;
    }
302956
public function getHttpAccept($httpAccept = null)
    {
        if (null === ($accept = $this->getServerValue('http_accept'))) {
            $accept = self::DEFAULT_HTTP_ACCEPT;
            $this->setHttpAccept($accept);
        }
        return $accept;
    }
1317895
public function setAccept($accept): void
    {
        // allow accept map
        $acceptMap = [
            'ANY' => Request::TYPE_ANY,
            'HTML' => Request::TYPE_HTML,
            'JSON' => Request::TYPE_JSON
        ];

        $accept = strtoupper($accept);

        if (isset($acceptMap[$accept])) {
            $this->accept[] = $acceptMap[$accept];
        }
    }
840032
public function getAcceptedContentTypes()
    {
        if (empty($this->acceptedContentTypes)) {
            // Values will be stored in this array
            $this->acceptedContentTypes = array();

            // Accept header is case insensitive, and whitespace isn’t important.
            $acceptHeader = strtolower(str_replace(' ', '', @$_SERVER['HTTP_ACCEPT'] ?: '*/*'));
            // Extract the content types from the header.
            $acceptHeaderItems = explode(',', $acceptHeader);
            foreach ($acceptHeaderItems as $contentType) {
                // The default quality is 1.
                $quality = 1;
                // Check whether a quality is specified.
                if (strpos($contentType, ';q=')) {
                    list($contentType, $quality) = explode(';q=', $contentType);
                }

                $this->acceptedContentTypes[$contentType] = $quality;
            }
            // Sort the content types by relevance.
            arsort($this->acceptedContentTypes);
        }

        return $this->acceptedContentTypes;
    }
876084
protected function setCharsets()
    {
        if ((count($this->charsets) === 0) && ! empty($_SERVER[ 'HTTP_ACCEPT_CHARSET' ])) {
            $this->charsets = explode(
                ',',
                preg_replace(
                    '/(;\s?q=.+)|\s/i',
                    '',
                    strtolower(trim($_SERVER[ 'HTTP_ACCEPT_CHARSET' ]))
                )
            );
        }

        if (count($this->charsets) === 0) {
            $this->charsets = ['Undefined'];
        }
    }
981821
protected function initLangAndLocale () {
		$rawUaLanguages = $this->globalServer['HTTP_ACCEPT_LANGUAGE'];
		if (extension_loaded('Intl')) {
			$langAndLocaleStr = \locale_accept_from_http($rawUaLanguages);
			$langAndLocaleArr = $langAndLocaleStr !== NULL
				? explode('_', $langAndLocaleStr)
				: [NULL, NULL];
		} else {
			$languagesAndLocales = static::ParseHttpAcceptLang($rawUaLanguages);
			$langAndLocaleArr = current($languagesAndLocales);
			if (is_array($langAndLocaleArr)) 
				$langAndLocaleArr = current($langAndLocaleArr);
		}
		if ($langAndLocaleArr[0] === NULL) $langAndLocaleArr[0] = '';
		if (count($langAndLocaleArr) > 1 && $langAndLocaleArr[1] === NULL) $langAndLocaleArr[1] = '';
		list($this->lang, $this->locale) = $langAndLocaleArr;
	}
984767
protected function checkLanguages($languageArguments)
    {
        $languages = $this->site->getStandardLanguages();
        $language_codes = array_keys($languages);
        $buildLanguages = [];
        foreach ($languageArguments as $language) {
            if (array_search($language, $language_codes)) {
                $buildLanguages[$language] = $languages[$language];
            } elseif ($language_code = array_search($language, $languages)) {
                $buildLanguages[$language_code] = $language;
            } else {
                $this->addMissingLanguage($language);
            }
        }
        return $buildLanguages;
    }
1199407
public function doesAcceptLanguage($language = 'en')
	{
		return (in_array(strtolower($language), $this->getAcceptLanguages(), true)) ? true : false;
	}
1047560
public function getLanguages()
    {
        $url = $this->getGetLanguagesUrl();
        $response = $this->sendRequest(
            'GET',
            $url,
            [
                'version' => $this->serviceProtocolVersion
            ]
        );
        if ($response->getStatusCode() === 200) {
            $languages = $this->parseGetLanguagesResponse($response);
            return $languages;
        }
        return false;
    }
1166299
private function parseAcceptLanguage(Request $request)
    {
        $locales = [];
        $acceptLanguage = trim($request->headers->get('Accept-Language'));

        if (!empty($acceptLanguage)) {
            $locales = array_map(function (AcceptLanguage $acceptLanguage) {
                return $acceptLanguage->getType();
            }, $this->localeNegotiator->parse($acceptLanguage));
        }

        return $locales;
    }
473079
private function resolveHeader()
    {
        if (null === static::$languages) {
            $httpLanguages = $this->request->server(config('localizer.request.header', 'HTTP_ACCEPT_LANGUAGE'));

            if (empty($httpLanguages)) {
                static::$languages = [];
            } else {
                $accepted = preg_split('/,\s*/', $httpLanguages);

                static::$languages = empty($languages = $this->buildCollection($accepted, $languages = []))
                    ? null
                    : array_keys($languages)[0];
            }
        }

        return static::$languages;
    }
442188
public function getAcceptableLanguages(?string $default = null): array
	{
		if(!isset($this->acceptableLanguages))
		{
			$this->acceptableLanguages = $this->parseAcceptHeader($this->get('accept-language'));
		}

		return $this->acceptableLanguages ?: (array) $default;
	}
652904
public function getAcceptableContentTypes()
    {
        if (null !== $this->acceptableContentTypes) {
            return $this->acceptableContentTypes;
        }

        return $this->acceptableContentTypes = array_keys(AcceptHeader::fromString($this->headers->get('Accept'))->all());
    }