You are here

public static function LingotekLocale::getLanguages in Lingotek Translation 3.4.x

Same name and namespace in other branches
  1. 8 src/LingotekLocale.php \Drupal\lingotek\LingotekLocale::getLanguages()
  2. 8.2 src/LingotekLocale.php \Drupal\lingotek\LingotekLocale::getLanguages()
  3. 4.0.x src/LingotekLocale.php \Drupal\lingotek\LingotekLocale::getLanguages()
  4. 3.0.x src/LingotekLocale.php \Drupal\lingotek\LingotekLocale::getLanguages()
  5. 3.1.x src/LingotekLocale.php \Drupal\lingotek\LingotekLocale::getLanguages()
  6. 3.2.x src/LingotekLocale.php \Drupal\lingotek\LingotekLocale::getLanguages()
  7. 3.3.x src/LingotekLocale.php \Drupal\lingotek\LingotekLocale::getLanguages()
  8. 3.5.x src/LingotekLocale.php \Drupal\lingotek\LingotekLocale::getLanguages()
  9. 3.6.x src/LingotekLocale.php \Drupal\lingotek\LingotekLocale::getLanguages()
  10. 3.7.x src/LingotekLocale.php \Drupal\lingotek\LingotekLocale::getLanguages()
  11. 3.8.x src/LingotekLocale.php \Drupal\lingotek\LingotekLocale::getLanguages()

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

Parameters

mixed $pluck_field: 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.

2 calls to LingotekLocale::getLanguages()
LingotekLocale::getLanguagesWithoutSource in src/LingotekLocale.php
LingotekLocale::getLanguagesWithoutSourceAsJSON in src/LingotekLocale.php

File

src/LingotekLocale.php, line 357

Class

LingotekLocale
A utility class for Lingotek translation.

Namespace

Drupal\lingotek

Code

public static function getLanguages($pluck_field = NULL, $include_disabled = FALSE, $lingotek_locale_to_exclude = NULL) {

  // lingotek_add_missing_locales(FALSE);
  $languages = [];
  foreach (\Drupal::languageManager()
    ->getLanguages() 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;

    // include all languages enabled
    if ($target_language->lingotek_enabled) {
      $languages[$target_language->lingotek_locale] = $language;

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