public function Lingotek::getDocumentTranslationStatus in Lingotek Translation 8
Same name and namespace in other branches
- 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.4.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()
Overrides LingotekInterface::getDocumentTranslationStatus
File
- src/
Lingotek.php, line 334 - Contains \Drupal\lingotek\Lingotek.
Class
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 = 0;
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'];
break;
}
}
}
if ($progress === self::PROGRESS_COMPLETE) {
return TRUE;
}
}
return FALSE;
}