You are here

function tmgmt_translator_load_available in Translation Management Tool 8

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

Loads all translators that are available and, if a translation job is given, support translations for that job with its current configuration.

Parameters

\Drupal\tmgmt\JobInterface $job: (Optional) A translation job.

Return value

array An array of translators with the machine-readable name of the translators as array keys.

Related topics

2 calls to tmgmt_translator_load_available()
JobCheckoutManager::needsCheckoutForm in src/JobCheckoutManager.php
Check if a job needs a checkout form.
tmgmt_job_needs_checkout_form in ./tmgmt.module
Check if a job needs a checkout form. The current checks include if there is more than one translator available, if he has settings and if the job has a fixed target language.

File

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

Code

function tmgmt_translator_load_available($job) {
  $translators = Translator::loadMultiple();
  foreach ($translators as $name => $translator) {
    if (!$translator
      ->checkAvailable()
      ->getSuccess() || isset($job) && !$translator
      ->checkTranslatable($job)
      ->getSuccess()) {
      unset($translators[$name]);
    }
  }
  return $translators;
}