public function LingotekInterfaceTranslationService::checkTargetStatuses in Lingotek Translation 3.5.x
Same name and namespace in other branches
- 4.0.x src/LingotekInterfaceTranslationService.php \Drupal\lingotek\LingotekInterfaceTranslationService::checkTargetStatuses()
- 3.2.x src/LingotekInterfaceTranslationService.php \Drupal\lingotek\LingotekInterfaceTranslationService::checkTargetStatuses()
- 3.3.x src/LingotekInterfaceTranslationService.php \Drupal\lingotek\LingotekInterfaceTranslationService::checkTargetStatuses()
- 3.4.x src/LingotekInterfaceTranslationService.php \Drupal\lingotek\LingotekInterfaceTranslationService::checkTargetStatuses()
- 3.6.x src/LingotekInterfaceTranslationService.php \Drupal\lingotek\LingotekInterfaceTranslationService::checkTargetStatuses()
- 3.7.x src/LingotekInterfaceTranslationService.php \Drupal\lingotek\LingotekInterfaceTranslationService::checkTargetStatuses()
- 3.8.x src/LingotekInterfaceTranslationService.php \Drupal\lingotek\LingotekInterfaceTranslationService::checkTargetStatuses()
Gets the current status of all the target translations.
Parameters
string $component: The component which status we want to check.
Overrides LingotekInterfaceTranslationServiceInterface::checkTargetStatuses
File
- src/
LingotekInterfaceTranslationService.php, line 190
Class
- LingotekInterfaceTranslationService
- Service for managing Lingotek interface translations.
Namespace
Drupal\lingotekCode
public function checkTargetStatuses($component) {
$document_id = $this
->getDocumentId($component);
$translation_statuses = $this->lingotek
->getDocumentTranslationStatuses($document_id);
$source_status = $this
->getSourceStatus($component);
$statuses = [];
$languages = $this->languageManager
->getLanguages();
foreach ($languages as $language) {
$statuses[$language
->getId()] = $this
->getTargetStatus($component, $language
->getId());
}
// Let's reset all statuses, but keep the source one.
$this
->clearTargetStatuses($component);
foreach ($translation_statuses as $lingotek_locale => $progress) {
$drupal_language = $this->languageLocaleMapper
->getConfigurableLanguageForLocale($lingotek_locale);
if ($drupal_language == NULL) {
// Language existing in TMS, but not configured on Drupal.
continue;
}
$langcode = $drupal_language
->id();
$current_target_status = $statuses[$langcode];
if (in_array($current_target_status, [
Lingotek::STATUS_UNTRACKED,
Lingotek::STATUS_DISABLED,
Lingotek::STATUS_EDITED,
Lingotek::STATUS_REQUEST,
Lingotek::STATUS_NONE,
Lingotek::STATUS_READY,
Lingotek::STATUS_PENDING,
Lingotek::STATUS_CANCELLED,
NULL,
])) {
if ($progress === Lingotek::STATUS_CANCELLED) {
$this
->setTargetStatus($component, $langcode, Lingotek::STATUS_CANCELLED);
}
elseif ($progress === Lingotek::PROGRESS_COMPLETE) {
$this
->setTargetStatus($component, $langcode, Lingotek::STATUS_READY);
}
else {
$this
->setTargetStatus($component, $langcode, Lingotek::STATUS_PENDING);
}
}
if ($source_status !== Lingotek::STATUS_CURRENT && $statuses[$langcode] === Lingotek::STATUS_EDITED && $langcode !== 'en') {
$this
->setTargetStatus($component, $langcode, Lingotek::STATUS_EDITED);
}
if ($source_status === Lingotek::STATUS_CURRENT && $statuses[$langcode] === Lingotek::STATUS_CURRENT && $langcode !== 'en') {
$this
->setTargetStatus($component, $langcode, Lingotek::STATUS_CURRENT);
}
}
}