function language_list

Returns a list of languages set up on the site.

Parameters

$flags: (optional) Specifies the state of the languages that have to be returned. It can be: Language::STATE_CONFIGURABLE, Language::STATE_LOCKED, Language::STATE_ALL.

Return value

array An associative array of languages, keyed by the language code, ordered by weight ascending and name ascending.

87 calls to language_list()
BlockFormController::form in drupal/core/modules/block/lib/Drupal/block/BlockFormController.php
Overrides \Drupal\Core\Entity\EntityFormController::form().
CommentLanguageTest::testCommentLanguage in drupal/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php
Test that comment language is properly set.
CommentTranslationUITest::assertPublishedStatus in drupal/core/modules/comment/lib/Drupal/comment/Tests/CommentTranslationUITest.php
Overrides \Drupal\translation_entity\Tests\EntityTranslationUITest::assertPublishedStatus().
DateFormatAddForm::buildForm in drupal/core/modules/system/lib/Drupal/system/Form/DateFormatAddForm.php
Form constructor.
DateFormatEditForm::buildForm in drupal/core/modules/system/lib/Drupal/system/Form/DateFormatEditForm.php
Form constructor.

... See full list

22 string references to 'language_list'
BlockLanguageTest::testLanguageBlockVisibility in drupal/core/modules/block/lib/Drupal/block/Tests/BlockLanguageTest.php
Tests the visibility settings for the blocks based on language.
CommentLanguageTest::testCommentLanguage in drupal/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php
Test that comment language is properly set.
LanguageConfigurationTest::checkConfigurableLanguageWeight in drupal/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationTest.php
Validates system languages are ordered after configurable languages.
LanguageListTest::testLanguageList in drupal/core/modules/language/lib/Drupal/language/Tests/LanguageListTest.php
Functional tests for adding, editing and deleting languages.
LanguageUILanguageNegotiationTest::testUILanguageNegotiation in drupal/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php
Tests for language switching by URL path.

... See full list

File

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

Code

function language_list($flags = Language::STATE_CONFIGURABLE) {
  $languages =& drupal_static(__FUNCTION__);

  // Initialize master language list.
  if (!isset($languages)) {

    // Initialize local language list cache.
    $languages = array();

    // Fill in master language list based on current configuration.
    $default = language_default();
    if (language_multilingual() || module_exists('language')) {

      // Use language module configuration if available.
      $languages = db_query('SELECT * FROM {language} ORDER BY weight ASC, name ASC')
        ->fetchAllAssoc('langcode', PDO::FETCH_ASSOC);

      // Initialize default property so callers have an easy reference and can
      // save the same object without data loss.
      foreach ($languages as $langcode => $info) {
        $info['default'] = $langcode == $default->langcode;
        $languages[$langcode] = new Language($info);
      }
    }
    else {

      // No language module, so use the default language only.
      $languages = array(
        $default->langcode => $default,
      );

      // Add the special languages, they will be filtered later if needed.
      $languages += language_default_locked_languages($default->weight);
    }
  }

  // Filter the full list of languages based on the value of the $all flag. By
  // default we remove the locked languages, but the caller may request for
  // those languages to be added as well.
  $filtered_languages = array();

  // Add the site's default language if flagged as allowed value.
  if ($flags & Language::STATE_SITE_DEFAULT) {
    $default = isset($default) ? $default : language_default();

    // Rename the default language.
    $default->name = t("Site's default language (@lang_name)", array(
      '@lang_name' => $default->name,
    ));
    $filtered_languages['site_default'] = $default;
  }
  foreach ($languages as $langcode => $language) {
    if ($language->locked && !($flags & Language::STATE_LOCKED) || !$language->locked && !($flags & Language::STATE_CONFIGURABLE)) {
      continue;
    }
    $filtered_languages[$langcode] = $language;
  }
  return $filtered_languages;
}