Returns a list of flagged translator labels.
If a translator is not available it will be suffixed with a short text explaining why it is not available. This can either be because the configuration of the passed job is not supported or because the translator service can't be reached.
\Drupal\tmgmt\JobInterface $job: (Optional) A translation job.
array An array of flagged translator labels.
function tmgmt_translator_labels_flagged(JobInterface $job = NULL) {
$labels = array();
$translators = Translator::loadMultiple();
uasort($translators, array(
'Drupal\\Core\\Config\\Entity\\ConfigEntityBase',
'sort',
));
/** @var \Drupal\tmgmt\Entity\Translator $translator */
foreach ($translators as $translator) {
if (isset($job) && $job
->isContinuous() && !$translator
->getPlugin() instanceof ContinuousTranslatorInterface) {
continue;
}
if (!$translator
->checkAvailable()
->getSuccess()) {
$labels[$translator
->id()] = t('@label (not available)', array(
'@label' => $translator
->label(),
));
}
elseif (isset($job) && !$translator
->checkTranslatable($job)
->getSuccess()) {
$labels[$translator
->id()] = t('@label (unsupported)', array(
'@label' => $translator
->label(),
));
}
else {
$labels[$translator
->id()] = $translator
->label();
}
}
return $labels;
}