protected function initLangSelect( $option = null ) {
		if ( $option !== null &&
			$option !== false &&
			$option !== '' &&
			$this->setLang( $option )
		) {
			return true;
		}

		if ( $this->getUseRequestParam() ) {
			$key = $this->paramNames['userlang'];
			if ( isset( $_GET[ $key ] ) && $this->setLang( $_GET[ $key ] ) ) {
				return true;
			}
			if ( isset( $_POST[ $key ] ) && $this->setLang( $_POST[ $key ] ) ) {
				return true;
			}
		}

		if ( isset( $_COOKIE[ $this->cookieNames['userlang'] ] ) ) {
			$set = $this->setLang( $_COOKIE[ $this->cookieNames['userlang'] ] );
			if ( $set ) {
				return true;
			}
		}

		$acceptableLanguages = IntuitionUtil::getAcceptableLanguages();
		foreach ( $acceptableLanguages as $acceptLang => $qVal ) {
			// If the lang code is known (we have a display name for it),
			// and we were able to set it, end the search.
			if ( $this->getLangName( $acceptLang ) && $this->setLang( $acceptLang ) ) {
				return true;
			}
		}

		// After this, we'll be choosing from
		// user-specified languages with a $qVal of 0.

		foreach ( $acceptableLanguages as $acceptLang => $qVal ) {
			// Some browsers show (apparently by default) only a tag,
			// such as "ru-RU", "fr-FR" or "es-mx". The browser should
			// provide a qval. Providing only a lang code is invalid.
			// See RFC 2616 section 1.4 <https://tools.ietf.org/html/rfc2616#page-105>.
			if ( !$qVal ) {
				continue;
			}

			// Progressively truncate $acceptLang (from the right) to each hyphen,
			// checking each time to see if the remaining string is an available language.
			while ( strpos( $acceptLang, '-' ) !== false ) {
				$acceptLang = substr( $acceptLang, 0, strrpos( $acceptLang, '-' ) );

				if ( $this->getLangName( $acceptLang ) && $this->setLang( $acceptLang ) ) {
					return true;
				}
			}
		}

		// Fallback
		return !!$this->setLang( 'en' );
	}
protected function initLangSelect( $option = null ) {
		if ( $option !== null &&
			$option !== false &&
			$option !== '' &&
			$this->setLang( $option )
		) {
			return true;
		}

		if ( $this->getUseRequestParam() ) {
			$key = $this->paramNames['userlang'];
			if ( isset( $_GET[ $key ] ) && $this->setLang( $_GET[ $key ] ) ) {
				return true;
			}
			if ( isset( $_POST[ $key ] ) && $this->setLang( $_POST[ $key ] ) ) {
				return true;
			}
		}

		if ( isset( $_COOKIE[ $this->cookieNames['userlang'] ] ) ) {
			$set = $this->setLang( $_COOKIE[ $this->cookieNames['userlang'] ] );
			if ( $set ) {
				return true;
			}
		}

		$acceptableLanguages = IntuitionUtil::getAcceptableLanguages();
		foreach ( $acceptableLanguages as $acceptLang => $qVal ) {
			// If the lang code is known (we have a display name for it),
			// and we were able to set it, end the search.
			if ( $this->getLangName( $acceptLang ) && $this->setLang( $acceptLang ) ) {
				return true;
			}
		}

		// After this, we'll be choosing from
		// user-specified languages with a $qVal of 0.

		foreach ( $acceptableLanguages as $acceptLang => $qVal ) {
			// Some browsers show (apparently by default) only a tag,
			// such as "ru-RU", "fr-FR" or "es-mx". The browser should
			// provide a qval. Providing only a lang code is invalid.
			// See RFC 2616 section 1.4 <https://tools.ietf.org/html/rfc2616#page-105>.
			if ( !$qVal ) {
				continue;
			}

			// Progressively truncate $acceptLang (from the right) to each hyphen,
			// checking each time to see if the remaining string is an available language.
			while ( strpos( $acceptLang, '-' ) !== false ) {
				$acceptLang = substr( $acceptLang, 0, strrpos( $acceptLang, '-' ) );

				if ( $this->getLangName( $acceptLang ) && $this->setLang( $acceptLang ) ) {
					return true;
				}
			}
		}

		// Fallback
		return !!$this->setLang( 'en' );
	}
protected function initLangSelect ( $ option = null ) { if ( $ option !== null && $ option !== false && $ option !== '' && $ this -> setLang ( $ option ) ) { return true ; } if ( $ this -> getUseRequestParam ( ) ) { $ key = $ this -> paramNames [ 'userlang' ] ; if ( isset ( $ _GET [ $ key ] ) && $ this -> setLang ( $ _GET [ $ key ] ) ) { return true ; } if ( isset ( $ _POST [ $ key ] ) && $ this -> setLang ( $ _POST [ $ key ] ) ) { return true ; } } if ( isset ( $ _COOKIE [ $ this -> cookieNames [ 'userlang' ] ] ) ) { $ set = $ this -> setLang ( $ _COOKIE [ $ this -> cookieNames [ 'userlang' ] ] ) ; if ( $ set ) { return true ; } } $ acceptableLanguages = IntuitionUtil :: getAcceptableLanguages ( ) ; foreach ( $ acceptableLanguages as $ acceptLang => $ qVal ) { // If the lang code is known (we have a display name for it), // and we were able to set it, end the search. if ( $ this -> getLangName ( $ acceptLang ) && $ this -> setLang ( $ acceptLang ) ) { return true ; } } // After this, we'll be choosing from // user-specified languages with a $qVal of 0. foreach ( $ acceptableLanguages as $ acceptLang => $ qVal ) { // Some browsers show (apparently by default) only a tag, // such as "ru-RU", "fr-FR" or "es-mx". The browser should // provide a qval. Providing only a lang code is invalid. // See RFC 2616 section 1.4 <https://tools.ietf.org/html/rfc2616#page-105>. if ( ! $ qVal ) { continue ; } // Progressively truncate $acceptLang (from the right) to each hyphen, // checking each time to see if the remaining string is an available language. while ( strpos ( $ acceptLang , '-' ) !== false ) { $ acceptLang = substr ( $ acceptLang , 0 , strrpos ( $ acceptLang , '-' ) ) ; if ( $ this -> getLangName ( $ acceptLang ) && $ this -> setLang ( $ acceptLang ) ) { return true ; } } } // Fallback return ! ! $ this -> setLang ( 'en' ) ; }
Check language choice tree.

In the following order:

1. Constructor option.
2. Request parameter.
3. Request cookie.
4. Request Accept-Language header (exactly).
5. Request Accept-Language header (prefix match).
6. Source fallback (English).

@param string|null|bool $option A language code, or null/false to traverse further down the
choice tree.
@return bool Whether a language was set or not.
Check language choice tree .