You are here

function language_fallback_get_candidates in Drupal 7

Returns the possible fallback languages ordered by language weight.

Parameters

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

Return value

An array of language codes.

Related topics

1 call to language_fallback_get_candidates()
locale_field_language_fallback in modules/locale/locale.module
Applies language fallback rules to the fields attached to the given entity.

File

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

Code

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;
}