You are here

function search_api_et_languages in Search API Entity Translation 7.2

Returns list of languages available/enabled on the site.

Parameters

bool $enabled_only: A boolean indicating whether to include all languages added to the site or only those enabled.

bool $include_neutral: A boolean indicating whether to add the neutral language (LANGUAGE_NONE) to the language list.

Return value

array An array with language codes as keys and language names as values.

See also

SearchApiAlterLanguageControl::configurationForm()

2 calls to search_api_et_languages()
search_api_et_form_search_api_admin_index_edit_alter in ./search_api_et.module
Implements hook_form_FORM_ID_alter() for search_api_admin_index_edit().
search_api_et_item_languages_all in ./search_api_et.inc
Get all enabled language for the site.

File

./search_api_et.module, line 231
Adds Entity Translation support to the Search API.

Code

function search_api_et_languages($enabled_only = FALSE, $include_neutral = TRUE) {
  $languages = array();
  if ($include_neutral) {
    $languages[LANGUAGE_NONE] = t('Language neutral');
  }
  $list = language_list();
  foreach ($list as $lang) {
    if ($enabled_only && !$lang->enabled) {
      continue;
    }
    $name = t($lang->name);
    $native = $lang->native;
    $languages[$lang->language] = $name == $native ? $name : $name . ' (' . $native . ')';
    if (!$enabled_only && !$lang->enabled) {
      $languages[$lang->language] .= ' [' . t('disabled') . ']';
    }
  }
  return $languages;
}