You are here

function tmgmt_available_languages in Translation Management Tool 8

Same name and namespace in other branches
  1. 7 tmgmt.module \tmgmt_available_languages()

Returns an array of languages that are available for translation.

Return value

array An array of languages in ISO format.

8 calls to tmgmt_available_languages()
CartForm::buildForm in src/Form/CartForm.php
Form constructor.
ContinuousJobForm::ajaxSourceLanguageSelect in src/Form/ContinuousJobForm.php
Ajax callback to fetch the options for target language select.
ContinuousJobForm::form in src/Form/ContinuousJobForm.php
Overrides Drupal\Core\Entity\EntityForm::form().
Job::preCreate in src/Entity/Job.php
Changes the values of an entity before it is created.
JobForm::form in src/Form/JobForm.php
Gets the actual form array to be built.

... See full list

File

./tmgmt.module, line 136
Main module file for the Translation Management module.

Code

function tmgmt_available_languages($exclude = array()) {
  $languages = \Drupal::languageManager()
    ->getLanguages();

  // Remove the language in $exclude from the list of available languages and
  // then apply a filter that only leaves the supported target languages on
  // the list.
  $labels = array();
  foreach ($languages as $langcode => $language) {
    if (!in_array($langcode, $exclude)) {
      $labels[$langcode] = $language
        ->getName();
    }
  }
  return $labels;
}