You are here

public function LingotekManagementForm::checkTranslationStatus in Lingotek Translation 8

Checks translation status for a given content in a given language.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: The entity.

string $language: The language to check.

File

src/Form/LingotekManagementForm.php, line 817
Contains \Drupal\Lingotek\Form\LingotekManagementForm.

Class

LingotekManagementForm
Form for bulk management of content.

Namespace

Drupal\lingotek\Form

Code

public function checkTranslationStatus(ContentEntityInterface $entity, $language, &$context) {
  $context['message'] = $this
    ->t('Checking translation status for @type %label to language @language.', [
    '@type' => $entity
      ->getEntityType()
      ->getLabel(),
    '%label' => $entity
      ->label(),
    '@language' => $language,
  ]);
  if ($profile = $this->lingotekConfiguration
    ->getEntityProfile($entity, FALSE)) {
    try {
      $this->translationService
        ->checkTargetStatus($entity, $language);
    } catch (LingotekApiException $exception) {
      drupal_set_message(t('The request for @entity_type %title translation status 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');
  }
}