function views_language_list

Prepares a list of language names.

This is a wrapper around language_list to return a plain key value array.

Parameters

string $field: The field of the language object which should be used as the value of the array.

int $flags: (optional) Specifies the state of the languages that have to be returned. It can be: LANGUAGE_CONFIGURABLE, LANGUAGE_LOCKED, LANGUAGE_ALL.

Return value

array An array of language names (or $field) keyed by the langcode.

See also

locale_language_list()

3 calls to views_language_list()
DisplayPluginBase::buildOptionsForm in drupal/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php
Provide the default form for setting options.
LanguageArgument::language in drupal/core/modules/language/lib/Drupal/language/Plugin/views/argument/LanguageArgument.php
Returns the language name for a given langcode.
LanguageFilter::get_value_options in drupal/core/modules/language/lib/Drupal/language/Plugin/views/filter/LanguageFilter.php
Child classes should be used to override this function and set the 'value options', unless 'options callback' is defined as a valid function or static public method to generate these values.

File

drupal/core/modules/views/views.module, line 914
Primarily Drupal hooks and global API functions to manipulate views.

Code

function views_language_list($field = 'name', $flags = LANGUAGE_ALL) {
  $languages = language_list($flags);
  $list = array();
  foreach ($languages as $language) {
    $list[$language->langcode] = $field == 'name' ? t($language->name) : $language->{$field};
  }
  return $list;
}