You are here

public function LingotekInterfaceTranslationService::checkTargetStatus in Lingotek Translation 4.0.x

Same name and namespace in other branches
  1. 3.2.x src/LingotekInterfaceTranslationService.php \Drupal\lingotek\LingotekInterfaceTranslationService::checkTargetStatus()
  2. 3.3.x src/LingotekInterfaceTranslationService.php \Drupal\lingotek\LingotekInterfaceTranslationService::checkTargetStatus()
  3. 3.4.x src/LingotekInterfaceTranslationService.php \Drupal\lingotek\LingotekInterfaceTranslationService::checkTargetStatus()
  4. 3.5.x src/LingotekInterfaceTranslationService.php \Drupal\lingotek\LingotekInterfaceTranslationService::checkTargetStatus()
  5. 3.6.x src/LingotekInterfaceTranslationService.php \Drupal\lingotek\LingotekInterfaceTranslationService::checkTargetStatus()
  6. 3.7.x src/LingotekInterfaceTranslationService.php \Drupal\lingotek\LingotekInterfaceTranslationService::checkTargetStatus()
  7. 3.8.x src/LingotekInterfaceTranslationService.php \Drupal\lingotek\LingotekInterfaceTranslationService::checkTargetStatus()

Gets the current status of the target translation.

Parameters

string $component: The component which status we want to check.

string $langcode: Translation language we want to check.

Return value

bool True if the component is uploaded succesfully.

Overrides LingotekInterfaceTranslationServiceInterface::checkTargetStatus

File

src/LingotekInterfaceTranslationService.php, line 272

Class

LingotekInterfaceTranslationService
Service for managing Lingotek interface translations.

Namespace

Drupal\lingotek

Code

public function checkTargetStatus($component, $langcode) {
  $current_status = $this
    ->getTargetStatus($component, $langcode);
  $locale = $this->languageLocaleMapper
    ->getLocaleForLangcode($langcode);
  $source_status = $this
    ->getSourceStatus($component);
  $document_id = $this
    ->getDocumentId($component);
  if ($langcode !== 'en') {
    if (($current_status == Lingotek::STATUS_PENDING || $current_status == Lingotek::STATUS_EDITED) && $source_status !== Lingotek::STATUS_EDITED) {
      $translation_status = $this->lingotek
        ->getDocumentTranslationStatus($document_id, $locale);
      if ($translation_status === Lingotek::STATUS_CANCELLED) {
        $this
          ->setTargetStatus($component, $langcode, Lingotek::STATUS_CANCELLED);
      }
      elseif ($translation_status === TRUE) {
        $current_status = Lingotek::STATUS_READY;
        $this
          ->setTargetStatus($component, $langcode, $current_status);
      }
      elseif ($this->lingotek
        ->downloadDocument($document_id, $locale)) {

        // TODO: Set Status to STATUS_READY_INTERIM when that status is
        // available. See ticket: https://www.drupal.org/node/2850548
      }
    }
    elseif ($current_status == Lingotek::STATUS_REQUEST || $current_status == Lingotek::STATUS_UNTRACKED) {
      $translation_status = $this->lingotek
        ->getDocumentTranslationStatus($document_id, $locale);
      if ($translation_status === TRUE) {
        $current_status = Lingotek::STATUS_READY;
        $this
          ->setTargetStatus($component, $langcode, $current_status);
      }
      elseif ($translation_status !== FALSE) {
        $current_status = Lingotek::STATUS_PENDING;
        $this
          ->setTargetStatus($component, $langcode, $current_status);
      }

      //elseif ($this->lingotek->downloadDocument($document_id, $locale)) {

      //   // TODO: Set Status to STATUS_READY_INTERIM when that status is
      //   // available. See ticket: https://www.drupal.org/node/2850548
      // }
    }
  }
  return $current_status;
}