public function LingotekContentTranslationService::checkTargetStatus in Lingotek Translation 8
Same name and namespace in other branches
- 8.2 src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::checkTargetStatus()
- 4.0.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::checkTargetStatus()
- 3.0.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::checkTargetStatus()
- 3.1.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::checkTargetStatus()
- 3.2.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::checkTargetStatus()
- 3.3.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::checkTargetStatus()
- 3.4.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::checkTargetStatus()
- 3.5.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::checkTargetStatus()
- 3.6.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::checkTargetStatus()
- 3.7.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::checkTargetStatus()
- 3.8.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::checkTargetStatus()
Gets the current status of the target translation.
Parameters
ContentEntityInterface &$entity: The entity which status we want to check.
string $langcode: Translation language we want to check.
Return value
boolean True if the entity is uploaded succesfully.
Overrides LingotekContentTranslationServiceInterface::checkTargetStatus
File
- src/
LingotekContentTranslationService.php, line 183 - Contains \Drupal\lingotek\LingotekContentTranslationService.
Class
- LingotekContentTranslationService
- Service for managing Lingotek content translations.
Namespace
Drupal\lingotekCode
public function checkTargetStatus(ContentEntityInterface &$entity, $langcode) {
$current_status = $this
->getTargetStatus($entity, $langcode);
$locale = $this->languageLocaleMapper
->getLocaleForLangcode($langcode);
$source_status = $this
->getSourceStatus($entity);
$document_id = $this
->getDocumentId($entity);
if ($langcode !== $entity
->getUntranslated()
->language()
->getId()) {
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) {
$current_status = Lingotek::STATUS_READY;
$this
->setTargetStatus($entity, $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($entity, $langcode, $current_status);
}
elseif ($translation_status !== FALSE) {
$current_status = Lingotek::STATUS_PENDING;
$this
->setTargetStatus($entity, $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;
}