public function LingotekManagementForm::requestTranslations in Lingotek Translation 8
Request all translations for a given content.
Parameters
\Drupal\Core\Entity\ContentEntityInterface $entity: The entity.
File
- src/
Form/ LingotekManagementForm.php, line 767 - Contains \Drupal\Lingotek\Form\LingotekManagementForm.
Class
- LingotekManagementForm
- Form for bulk management of content.
Namespace
Drupal\lingotek\FormCode
public function requestTranslations(ContentEntityInterface $entity, $language, &$context) {
$result = NULL;
$context['message'] = $this
->t('Requesting translations for @type %label.', [
'@type' => $entity
->getEntityType()
->getLabel(),
'%label' => $entity
->label(),
]);
if ($profile = $this->lingotekConfiguration
->getEntityProfile($entity, FALSE)) {
try {
$result = $this->translationService
->requestTranslations($entity);
} catch (LingotekApiException $exception) {
drupal_set_message(t('The request for @entity_type %title translation failed. Please try again.', array(
'@entity_type' => $entity
->getEntityTypeId(),
'%title' => $entity
->label(),
)), 'error');
}
}
else {
$bundleInfos = $this->entityManager
->getBundleInfo($entity
->getEntityTypeId());
drupal_set_message($this
->t('The @type %label has no profile assigned so it was not processed.', [
'@type' => $bundleInfos[$entity
->bundle()]['label'],
'%label' => $entity
->label(),
]), 'warning');
}
return $result;
}