You are here

function views_language_list in Views (for Drupal 7) 8.3

Same name and namespace in other branches
  1. 6.3 views.module \views_language_list()
  2. 7.3 views.module \views_language_list()

Returns an array of language names.

This is a one to one copy of locale_language_list because we can't rely on enabled locale module.

@todo Figure out whether we need this with language module.

Parameters

$field: 'name' => names in current language, localized 'native' => native names

$all: Boolean to return all languages or only enabled ones

See also

locale_language_list()

4 calls to views_language_list()
DisplayPluginBase::buildOptionsForm in lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php
Provide the default form for setting options.
Language::get_value_options in lib/Views/language/Plugin/views/filter/Language.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.
Language::language in lib/Views/language/Plugin/views/argument/Language.php
Translation::buildOptionsForm in lib/Views/translation/Plugin/views/relationship/Translation.php
Add a translation selector.

File

./views.module, line 986
Primarily Drupal hooks and global API functions to manipulate views.

Code

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