7.x language.inc language_fallback_get_candidates($type = LANGUAGE_TYPE_CONTENT)

Returns the possible fallback languages ordered by language weight.


(optional) The language type. Defaults to LANGUAGE_TYPE_CONTENT.:

Return value

An array of language codes.

Related topics


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


function language_fallback_get_candidates($type = LANGUAGE_TYPE_CONTENT) {
  $fallback_candidates =& drupal_static(__FUNCTION__);
  if (!isset($fallback_candidates)) {
    $fallback_candidates = array();

    // Get languages ordered by weight.
    // Use array keys to avoid duplicated entries.
    foreach (language_list('weight') as $languages) {
      foreach ($languages as $language) {
        $fallback_candidates[$language->language] = NULL;
    $fallback_candidates = array_keys($fallback_candidates);
    $fallback_candidates[] = LANGUAGE_NONE;

    // Let other modules hook in and add/change candidates.
    drupal_alter('language_fallback_candidates', $fallback_candidates);
  return $fallback_candidates;