function language_list

7.x bootstrap.inc language_list($field = 'language')
6.x bootstrap.inc language_list($field = 'language', $reset = FALSE)
8.x bootstrap.inc language_list($flags = LanguageInterface::STATE_CONFIGURABLE)

Returns a list of installed languages, indexed by the specified key.

Parameters

$field: (optional) The field to index the list with.

Return value

An associative array, keyed on the values of $field.

  • If $field is 'weight' or 'enabled', the array is nested, with the outer array's values each being associative arrays with language codes as keys and language objects as values.
  • For all other values of $field, the array is only one level deep, and the array's values are language objects.
46 calls to language_list()
field_content_languages in drupal/modules/field/field.multilingual.inc
Returns available content languages.
language_fallback_get_candidates in drupal/includes/language.inc
Returns the possible fallback languages ordered by language weight.
language_negotiation_get_switch_links in drupal/includes/language.inc
Returns the language switch links for the given language.
language_provider_invoke in drupal/includes/language.inc
Helper function used to cache the language negotiation providers results.
LocaleCommentLanguageFunctionalTest::testCommentLanguage in drupal/modules/locale/locale.test
Test that comment language is properly set.

... See full list

14 string references to 'language_list'
LocaleCommentLanguageFunctionalTest::testCommentLanguage in drupal/modules/locale/locale.test
Test that comment language is properly set.
LocaleConfigurationTest::testLanguageConfiguration in drupal/modules/locale/locale.test
Functional tests for adding, editing and deleting languages.
LocaleTranslationFunctionalTest::testJavaScriptTranslation in drupal/modules/locale/locale.test
LocaleUILanguageNegotiationTest::testUILanguageNegotiation in drupal/modules/locale/locale.test
Tests for language switching by URL path.
LocaleUrlRewritingTest::setUp in drupal/modules/locale/locale.test
Sets up a Drupal site for running functional and integration tests.

... See full list

File

drupal/includes/bootstrap.inc, line 2741
Functions that need to be loaded on every Drupal request.

Code

function language_list($field = 'language') {
  $languages = &drupal_static(__FUNCTION__);
  // Init language list
  if (!isset($languages)) {
    if (drupal_multilingual() || module_exists('locale')) {
      $languages['language'] = db_query('SELECT * FROM {languages} ORDER BY weight ASC, name ASC')->fetchAllAssoc('language');
      // Users cannot uninstall the native English language. However, we allow
      // it to be hidden from the installed languages. Therefore, at least one
      // other language must be enabled then.
      if (!$languages['language']['en']->enabled && !variable_get('language_native_enabled', TRUE)) {
        unset($languages['language']['en']);
      }
    }
    else {
      // No locale module, so use the default language only.
      $default = language_default();
      $languages['language'][$default->language] = $default;
    }
  }

  // Return the array indexed by the right field
  if (!isset($languages[$field])) {
    $languages[$field] = array();
    foreach ($languages['language'] as $lang) {
      // Some values should be collected into an array
      if (in_array($field, array('enabled', 'weight'))) {
        $languages[$field][$lang->$field][$lang->language] = $lang;
      }
      else {
        $languages[$field][$lang->$field] = $lang;
      }
    }
  }
  return $languages[$field];
}