public function Lingotek::getDocumentTranslationStatus in Lingotek Translation 3.4.x
Same name and namespace in other branches
- 8 src/Lingotek.php \Drupal\lingotek\Lingotek::getDocumentTranslationStatus()
- 8.2 src/Lingotek.php \Drupal\lingotek\Lingotek::getDocumentTranslationStatus()
- 4.0.x src/Lingotek.php \Drupal\lingotek\Lingotek::getDocumentTranslationStatus()
- 3.0.x src/Lingotek.php \Drupal\lingotek\Lingotek::getDocumentTranslationStatus()
- 3.1.x src/Lingotek.php \Drupal\lingotek\Lingotek::getDocumentTranslationStatus()
- 3.2.x src/Lingotek.php \Drupal\lingotek\Lingotek::getDocumentTranslationStatus()
- 3.3.x src/Lingotek.php \Drupal\lingotek\Lingotek::getDocumentTranslationStatus()
- 3.5.x src/Lingotek.php \Drupal\lingotek\Lingotek::getDocumentTranslationStatus()
- 3.6.x src/Lingotek.php \Drupal\lingotek\Lingotek::getDocumentTranslationStatus()
- 3.7.x src/Lingotek.php \Drupal\lingotek\Lingotek::getDocumentTranslationStatus()
- 3.8.x src/Lingotek.php \Drupal\lingotek\Lingotek::getDocumentTranslationStatus()
Gets the status of the translation.
Parameters
string $doc_id: The document ID in Lingotek.
$locale: The locale we want to know the translation status.
Return value
bool|int Returns TRUE if the document translation is completed. FALSE if it was not requested. The percentage if it's still in progress.
Overrides LingotekInterface::getDocumentTranslationStatus
File
- src/
Lingotek.php, line 724
Class
- Lingotek
- The connecting class between Drupal and Lingotek
Namespace
Drupal\lingotekCode
public function getDocumentTranslationStatus($doc_id, $locale) {
// For now, a passthrough to the API object so the controllers do not
// need to include that class.
$response = $this->api
->getDocumentTranslationStatus($doc_id, $locale);
$progress = FALSE;
if ($response
->getStatusCode() == Response::HTTP_OK) {
$progress_json = json_decode($response
->getBody(), TRUE);
$lingotek_locale = str_replace("_", "-", $locale);
if (!empty($progress_json['entities'])) {
foreach ($progress_json['entities'] as $index => $data) {
if ($data['properties']['locale_code'] === $lingotek_locale) {
$progress = $data['properties']['percent_complete'];
if ($data['properties']['status'] === Lingotek::STATUS_CANCELLED) {
$progress = $data['properties']['status'];
}
break;
}
}
}
if ($progress === self::PROGRESS_COMPLETE) {
return TRUE;
}
}
return $progress;
}