UserAgent::getBestMatchingLangcode

public static function UserAgent::getBestMatchingLangcode

public static UserAgent::getBestMatchingLangcode($http_accept_language, $langcodes, $mappings = array())

Identifies user agent language from the Accept-language HTTP header.

The algorithm works as follows:

  • map user agent language codes to available language codes.
  • order all user agent language codes by qvalue from high to low.
  • add generic user agent language codes if they aren't already specified but with a slightly lower qvalue.
  • find the most specific available language code with the highest qvalue.
  • if 2 or more languages are having the same qvalue, respect the order of them inside the $languages array.

We perform user agent accept-language parsing only if page cache is disabled, otherwise we