src/I18nContext.php
public static function parseAcceptLanguage() {
		if ( !isset( $_SERVER['HTTP_ACCEPT_LANGUAGE'] ) ) {
			return array();
		}

		$weighted = array();

		// Strip any whitespace in the header value
		$hdr = preg_replace( '/\s+/', '', $_SERVER['HTTP_ACCEPT_LANGUAGE'] );
		// Split on commas
		$parts = explode( ',', $hdr );
		foreach ( $parts as $idx => $part ) {
			if ( strpos( $part, ';q=' ) ) {
				// Extract relative weight from component
				list( $lang, $weight ) = explode( ';q=', $part );
				$weight = (float)$weight;

			} else {
				$lang = $part;
				$weight = 1;
			}

			if ( $lang != '*' && $weight > 0 ) {
				// Decorate the weight with the original position to make sort
				// stable
				$weighted[strtolower( $lang )] = array( $weight, -$idx );
			}
		}

		arsort( $weighted );
		return array_keys( $weighted );
	}
public static function parseAcceptLanguage() {
		if ( !isset( $_SERVER['HTTP_ACCEPT_LANGUAGE'] ) ) {
			return array();
		}

		$weighted = array();

		// Strip any whitespace in the header value
		$hdr = preg_replace( '/\s+/', '', $_SERVER['HTTP_ACCEPT_LANGUAGE'] );
		// Split on commas
		$parts = explode( ',', $hdr );
		foreach ( $parts as $idx => $part ) {
			if ( strpos( $part, ';q=' ) ) {
				// Extract relative weight from component
				list( $lang, $weight ) = explode( ';q=', $part );
				$weight = (float)$weight;

			} else {
				$lang = $part;
				$weight = 1;
			}

			if ( $lang != '*' && $weight > 0 ) {
				// Decorate the weight with the original position to make sort
				// stable
				$weighted[strtolower( $lang )] = array( $weight, -$idx );
			}
		}

		arsort( $weighted );
		return array_keys( $weighted );
	}
Parse the Accept-Language header present in the request and return an
ordered list of languages preferred by the user-agent.

@return array List of preferred languages