You are here

protected function LingotekConfigManagementForm::performTranslationDownload in Lingotek Translation 8

Same name and namespace in other branches
  1. 8.2 src/Form/LingotekConfigManagementForm.php \Drupal\lingotek\Form\LingotekConfigManagementForm::performTranslationDownload()
  2. 4.0.x src/Form/LingotekConfigManagementForm.php \Drupal\lingotek\Form\LingotekConfigManagementForm::performTranslationDownload()
  3. 3.0.x src/Form/LingotekConfigManagementForm.php \Drupal\lingotek\Form\LingotekConfigManagementForm::performTranslationDownload()
  4. 3.1.x src/Form/LingotekConfigManagementForm.php \Drupal\lingotek\Form\LingotekConfigManagementForm::performTranslationDownload()
  5. 3.2.x src/Form/LingotekConfigManagementForm.php \Drupal\lingotek\Form\LingotekConfigManagementForm::performTranslationDownload()
  6. 3.3.x src/Form/LingotekConfigManagementForm.php \Drupal\lingotek\Form\LingotekConfigManagementForm::performTranslationDownload()
  7. 3.4.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 1370
Contains \Drupal\Lingotek\Form\LingotekConfigManagementForm.

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 {
      $this->translationService
        ->downloadDocument($entity, $locale);
    } catch (LingotekApiException $e) {
      drupal_set_message($this
        ->t('%label @locale translation download failed. Please try again.', [
        '%label' => $entity
          ->label(),
        '@locale' => $locale,
      ]), 'error');
    }
  }
  else {
    try {
      $this->translationService
        ->downloadConfig($mapper
        ->getPluginId(), $locale);
    } catch (LingotekApiException $e) {
      drupal_set_message($this
        ->t('%label @locale translation download failed. Please try again.', [
        '%label' => $mapper
          ->getTitle(),
        '@locale' => $locale,
      ]), 'error');
    }
  }
}