You are here

protected function LingotekConfigManagementForm::performTranslationDownload in Lingotek Translation 3.4.x

Same name and namespace in other branches
  1. 8 src/Form/LingotekConfigManagementForm.php \Drupal\lingotek\Form\LingotekConfigManagementForm::performTranslationDownload()
  2. 8.2 src/Form/LingotekConfigManagementForm.php \Drupal\lingotek\Form\LingotekConfigManagementForm::performTranslationDownload()
  3. 4.0.x src/Form/LingotekConfigManagementForm.php \Drupal\lingotek\Form\LingotekConfigManagementForm::performTranslationDownload()
  4. 3.0.x src/Form/LingotekConfigManagementForm.php \Drupal\lingotek\Form\LingotekConfigManagementForm::performTranslationDownload()
  5. 3.1.x src/Form/LingotekConfigManagementForm.php \Drupal\lingotek\Form\LingotekConfigManagementForm::performTranslationDownload()
  6. 3.2.x src/Form/LingotekConfigManagementForm.php \Drupal\lingotek\Form\LingotekConfigManagementForm::performTranslationDownload()
  7. 3.3.x src/Form/LingotekConfigManagementForm.php \Drupal\lingotek\Form\LingotekConfigManagementForm::performTranslationDownload()
  8. 3.5.x src/Form/LingotekConfigManagementForm.php \Drupal\lingotek\Form\LingotekConfigManagementForm::performTranslationDownload()
  9. 3.6.x src/Form/LingotekConfigManagementForm.php \Drupal\lingotek\Form\LingotekConfigManagementForm::performTranslationDownload()
  10. 3.7.x src/Form/LingotekConfigManagementForm.php \Drupal\lingotek\Form\LingotekConfigManagementForm::performTranslationDownload()
  11. 3.8.x src/Form/LingotekConfigManagementForm.php \Drupal\lingotek\Form\LingotekConfigManagementForm::performTranslationDownload()

Actually performs the translation download.

Parameters

\Drupal\config_translation\ConfigMapperInterface $mapper: The mapper to be used.

$entity: The entity (in case it is a config entity mapper).

$locale: The locale to be downloaded.

2 calls to LingotekConfigManagementForm::performTranslationDownload()
LingotekConfigManagementForm::downloadTranslation in src/Form/LingotekConfigManagementForm.php
Download translation for a given content in a given language.
LingotekConfigManagementForm::downloadTranslations in src/Form/LingotekConfigManagementForm.php
Download translations for a given content in all enabled languages.

File

src/Form/LingotekConfigManagementForm.php, line 1746

Class

LingotekConfigManagementForm
Form for bulk management of content.

Namespace

Drupal\lingotek\Form

Code

protected function performTranslationDownload(ConfigMapperInterface $mapper, $entity, $locale) {
  if ($mapper instanceof ConfigEntityMapper) {
    try {
      if ($this->translationService
        ->checkTargetStatus($entity, $locale)) {
        $success = $this->translationService
          ->downloadDocument($entity, $locale);
        if ($success === FALSE) {
          $this
            ->messenger()
            ->addError($this
            ->t('%label @locale translation download failed. Please try again.', [
            '%label' => $entity
              ->label(),
            '@locale' => $locale,
          ]));
        }
      }
    } catch (LingotekApiException $e) {
      $this
        ->messenger()
        ->addError($this
        ->t('%label @locale translation download failed. Please try again.', [
        '%label' => $entity
          ->label(),
        '@locale' => $locale,
      ]));
    }
  }
  else {
    try {
      if ($this->translationService
        ->checkConfigTargetStatus($mapper
        ->getPluginId(), $locale)) {
        $success = $this->translationService
          ->downloadConfig($mapper
          ->getPluginId(), $locale);
        if ($success === FALSE) {
          $this
            ->messenger()
            ->addError($this
            ->t('%label @locale translation download failed. Please try again.', [
            '%label' => $mapper
              ->getTitle(),
            '@locale' => $locale,
          ]));
        }
      }
    } catch (LingotekApiException $e) {
      $this
        ->messenger()
        ->addError($this
        ->t('%label @locale translation download failed. Please try again.', [
        '%label' => $mapper
          ->getTitle(),
        '@locale' => $locale,
      ]));
    }
  }
}