public static function parseAccept(string $accept, bool $is_lang)
    {
        // By default accept everything but prefer HTML
        if (empty($accept))
            $accept = "text/html;q=1.0,*/*;q=0.9";

        // Normalize locales when the intl extension is available
        $is_lang = $is_lang && class_exists('Locale', false);

		$accept = explode(",", $accept);
        $accepted = array();
		foreach ($accept as $type)
		{
			if (preg_match("/^([^;]+);q=([\d.]+)$/", $type, $matches))
			{
				$type = $matches[1];
				$prio = (float)$matches[2];
			}
			else
				$prio = 1.0;

            if ($is_lang)
                $type = \Locale::canonicalize($type);

			$accepted[$type] = $prio;
		}

        return $accepted;
    }