public function LingotekFake::getDocumentTranslationStatus in Lingotek Translation 3.8.x
Same name and namespace in other branches
- 8 tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::getDocumentTranslationStatus()
- 8.2 tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::getDocumentTranslationStatus()
- 4.0.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::getDocumentTranslationStatus()
- 3.0.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::getDocumentTranslationStatus()
- 3.1.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::getDocumentTranslationStatus()
- 3.2.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::getDocumentTranslationStatus()
- 3.3.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::getDocumentTranslationStatus()
- 3.4.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::getDocumentTranslationStatus()
- 3.5.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::getDocumentTranslationStatus()
- 3.6.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::getDocumentTranslationStatus()
- 3.7.x tests/modules/lingotek_test/src/LingotekFake.php \Drupal\lingotek_test\LingotekFake::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.
Throws
\Drupal\lingotek\Exception\LingotekDocumentNotFoundException
Overrides LingotekInterface::getDocumentTranslationStatus
File
- tests/
modules/ lingotek_test/ src/ LingotekFake.php, line 305
Class
Namespace
Drupal\lingotek_testCode
public function getDocumentTranslationStatus($doc_id, $locale) {
if (\Drupal::state()
->get('lingotek.must_error_in_check_target_status', FALSE)) {
\Drupal::state()
->set('lingotek.must_error_in_check_target_status', FALSE);
throw new LingotekApiException('Error was forced.');
}
if (\Drupal::state()
->get('lingotek.must_document_not_found_error_in_check_target_status', FALSE)) {
throw new LingotekDocumentNotFoundException($doc_id . ' not found. Error was forced.');
}
\Drupal::state()
->set('lingotek.checked_target_locale', $locale);
// Return true if translation is done.
if (\Drupal::state()
->get('lingotek.document_completion', NULL) === NULL) {
$result = TRUE;
$requested_locales = \Drupal::state()
->get('lingotek.requested_locales', []);
if (!isset($requested_locales[$doc_id]) || !in_array($locale, $requested_locales[$doc_id])) {
$result = FALSE;
}
$cancelled_locales = \Drupal::state()
->get('lingotek.cancelled_locales', []);
if (isset($cancelled_locales[$doc_id]) && in_array($locale, $cancelled_locales[$doc_id])) {
$result = 'CANCELLED';
}
return $result;
}
return \Drupal::state()
->get('lingotek.document_completion', TRUE);
}