You are here

public static function Lingotek::getLanguages in Lingotek Translation 7.7

Same name and namespace in other branches
  1. 7.5 lib/Drupal/lingotek/Lingotek.php \Lingotek::getLanguages()
  2. 7.6 lib/Drupal/lingotek/Lingotek.php \Lingotek::getLanguages()

Gets the site's available target languages for Lingotek translation.

Parameters

$pluck_field - mixed: NULL - return the entire object string - return an array of just the pluck_field specified (if it exists) array - return an array of the selected fields

Return value

array An array of Lingotek language codes.

9 calls to Lingotek::getLanguages()
Lingotek::getLanguagesWithoutSource in lib/Drupal/lingotek/Lingotek.php
Lingotek::getLanguagesWithoutSourceAsJSON in lib/Drupal/lingotek/Lingotek.php
lingotek_bulk_grid_parse_config_data in ./lingotek.config.inc
lingotek_config_download_selected in ./lingotek.config.inc
lingotek_get_language_details in ./lingotek.dashboard.inc
Get the details of each language

... See full list

File

lib/Drupal/lingotek/Lingotek.php, line 369
Defines Lingotek.

Class

Lingotek
A utility class for Lingotek translation.

Code

public static function getLanguages($pluck_field = NULL, $include_disabled = FALSE, $lingotek_locale_to_exclude = NULL) {
  lingotek_add_missing_locales(FALSE);
  $languages = array();
  foreach (language_list() as $target_language) {
    if ($target_language->lingotek_locale == $lingotek_locale_to_exclude) {
      continue;
    }
    $language = is_string($pluck_field) && isset($target_language->{$pluck_field}) ? $target_language->{$pluck_field} : $target_language;
    if ($target_language->lingotek_enabled) {

      // include all languages enabled
      $languages[$target_language->lingotek_locale] = $language;
    }
    elseif ($include_disabled) {

      // include all languages, including disabled (lingotek_enabled is 0)
      $languages[$target_language->lingotek_locale] = $language;
    }
  }
  return $languages;
}