You are here

public static function Lingotek::availableLanguageTargets in Lingotek Translation 7.3

Same name and namespace in other branches
  1. 7.2 lib/Drupal/lingotek/Lingotek.php \Lingotek::availableLanguageTargets()
  2. 7.4 lib/Drupal/lingotek/Lingotek.php \Lingotek::availableLanguageTargets()

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.

7 calls to Lingotek::availableLanguageTargets()
Lingotek::availableLanguageTargetsWithoutSource in lib/Drupal/lingotek/Lingotek.php
Lingotek::availableLanguageTargetsWithoutSourceAsJSON in lib/Drupal/lingotek/Lingotek.php
LingotekApi::getConfigChunkCreateWithTargetsParams in lib/Drupal/lingotek/LingotekApi.php
Gets the config-chunk-specific parameters for use in a createContentDocumentWithTargets API call.
LingotekSync::setNodeAndTargetsStatus in lib/Drupal/lingotek/LingotekSync.php
lingotek_form_bulk_sync in ./lingotek.sync.inc

... See full list

File

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

Class

Lingotek
A utility class for Lingotek translation.

Code

public static function availableLanguageTargets($pluck_field = NULL, $include_all = FALSE, $lingotek_locale_to_exclude = NULL) {

  //lingotek_add_missing_locales();
  $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 ($include_all && $target_language->enabled) {

      // include all languages enabled (not necessarily lingotek_enabled)
      $languages[] = $language;
    }
    else {
      if ($target_language->lingotek_enabled) {

        // include default language for free
        $languages[] = $language;
      }
    }
  }
  return $languages;
}