1.20.x language.inc language_negotiation_get($type, $provider_id = NULL)

Checks whether a language negotiation provider is enabled for a language type.

This has two possible behaviors:

  • If $provider_id is given return its ID if enabled, FALSE otherwise.
  • If no ID is passed the first enabled language negotiation provider is returned.

Parameters

$type: The language negotiation provider type.

$provider_id: The language negotiation provider ID.

Return value

The provider ID if it is enabled, FALSE otherwise.:

Related topics

File

includes/language.inc, line 203
Language Negotiation API.

Code

function language_negotiation_get($type, $provider_id = NULL) {
  $negotiation = language_negotiation_order($type);

  if (empty($negotiation)) {
    return empty($provider_id) ? LANGUAGE_NEGOTIATION_DEFAULT : FALSE;
  }

  if (empty($provider_id)) {
    return reset($negotiation);
  }

  if (in_array($provider_id, $negotiation)) {
    return $provider_id;
  }

  return FALSE;
}