You are here

public function LingotekConfigManagementForm::downloadTranslation in Lingotek Translation 8

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

Download translation for a given content in a given language.

Parameters

\Drupal\config_translation\ConfigMapperInterface $mapper: The mapper.

string $langcode: The language to download.

File

src/Form/LingotekConfigManagementForm.php, line 882
Contains \Drupal\Lingotek\Form\LingotekConfigManagementForm.

Class

LingotekConfigManagementForm
Form for bulk management of content.

Namespace

Drupal\lingotek\Form

Code

public function downloadTranslation(ConfigMapperInterface $mapper, $langcode, &$context) {
  $context['message'] = $this
    ->t('Downloading translation for %label in language @language.', [
    '%label' => $mapper
      ->getTitle(),
    '@language' => $langcode,
  ]);
  $locale = $this->languageLocaleMapper
    ->getLocaleForLangcode($langcode);
  $entity = $mapper instanceof ConfigEntityMapper ? $mapper
    ->getEntity() : NULL;
  $profile = $mapper instanceof ConfigEntityMapper ? $this->lingotekConfiguration
    ->getConfigEntityProfile($entity, FALSE) : $this->lingotekConfiguration
    ->getConfigProfile($mapper
    ->getPluginId(), FALSE);

  // If there is no entity, it's a config object and we don't abort based on
  // the profile.
  if ($entity === NULL || $profile !== NULL) {
    $this
      ->performTranslationDownload($mapper, $entity, $locale);
  }
  else {
    drupal_set_message($this
      ->t('%label has no profile assigned so it was not processed.', [
      '%label' => $mapper
        ->getTitle(),
    ]), 'warning');
  }
}