You are here

function language_list in Drupal 6

Same name and namespace in other branches
  1. 7 includes/bootstrap.inc \language_list()

Get a list of languages set up indexed by the specified key

Parameters

$field The field to index the list with.:

$reset Boolean to request a reset of the list.:

25 calls to language_list()
language_from_browser in includes/language.inc
Identify language from the Accept-language HTTP header we got.
language_initialize in includes/language.inc
Choose a language for the page, based on language negotiation settings.
locale_batch_by_component in includes/locale.inc
Prepare a batch to run when installing modules or enabling themes. This batch will import translations for the newly added components in all the languages already set up on the site.
locale_block in modules/locale/locale.module
Implementation of hook_block(). Displays a language switcher. Translation links may be provided by other modules.
locale_get_plural in modules/locale/locale.module
Returns plural form index for a specific number.

... See full list

File

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

Code

function language_list($field = 'language', $reset = FALSE) {
  static $languages = NULL;

  // Reset language list
  if ($reset) {
    $languages = NULL;
  }

  // Init language list
  if (!isset($languages)) {
    if (variable_get('language_count', 1) > 1 || module_exists('locale')) {
      $result = db_query('SELECT * FROM {languages} ORDER BY weight ASC, name ASC');
      while ($row = db_fetch_object($result)) {
        $languages['language'][$row->language] = $row;
      }
    }
    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];
}