public function LingotekInterfaceTranslationService::setTargetStatuses in Lingotek Translation 3.5.x
Same name and namespace in other branches
- 4.0.x src/LingotekInterfaceTranslationService.php \Drupal\lingotek\LingotekInterfaceTranslationService::setTargetStatuses()
- 3.2.x src/LingotekInterfaceTranslationService.php \Drupal\lingotek\LingotekInterfaceTranslationService::setTargetStatuses()
- 3.3.x src/LingotekInterfaceTranslationService.php \Drupal\lingotek\LingotekInterfaceTranslationService::setTargetStatuses()
- 3.4.x src/LingotekInterfaceTranslationService.php \Drupal\lingotek\LingotekInterfaceTranslationService::setTargetStatuses()
- 3.6.x src/LingotekInterfaceTranslationService.php \Drupal\lingotek\LingotekInterfaceTranslationService::setTargetStatuses()
- 3.7.x src/LingotekInterfaceTranslationService.php \Drupal\lingotek\LingotekInterfaceTranslationService::setTargetStatuses()
- 3.8.x src/LingotekInterfaceTranslationService.php \Drupal\lingotek\LingotekInterfaceTranslationService::setTargetStatuses()
Sets the translation status of all translations of a given component.
Parameters
string $component: The component which status we want to change.
int $status: Status of the translation. Use Lingotek constants.
Return value
string
Overrides LingotekInterfaceTranslationServiceInterface::setTargetStatuses
3 calls to LingotekInterfaceTranslationService::setTargetStatuses()
- LingotekInterfaceTranslationService::cancelDocument in src/
LingotekInterfaceTranslationService.php - Cancels a document from the server.
- LingotekInterfaceTranslationService::updateDocument in src/
LingotekInterfaceTranslationService.php - Resends a document to the translation service.
- LingotekInterfaceTranslationService::uploadDocument in src/
LingotekInterfaceTranslationService.php - Uploads a document to the Lingotek service.
File
- src/
LingotekInterfaceTranslationService.php, line 312
Class
- LingotekInterfaceTranslationService
- Service for managing Lingotek interface translations.
Namespace
Drupal\lingotekCode
public function setTargetStatuses($component, $status) {
$target_languages = $this->languageManager
->getLanguages();
$source_langcode = 'en';
foreach ($target_languages as $langcode => $language) {
if ($langcode != $source_langcode && ($current_status = $this
->getTargetStatus($component, $langcode))) {
if ($current_status === Lingotek::STATUS_PENDING && $status === Lingotek::STATUS_REQUEST) {
// Don't allow to pass from pending to request. We have been already
// requested this one.
continue;
}
if (in_array($current_status, [
Lingotek::STATUS_UNTRACKED,
Lingotek::STATUS_REQUEST,
Lingotek::STATUS_DISABLED,
NULL,
]) && $status === Lingotek::STATUS_PENDING) {
continue;
}
if ($current_status == $status) {
continue;
}
if ($current_status != Lingotek::STATUS_EDITED && $current_status !== Lingotek::STATUS_CURRENT) {
$this
->setTargetStatus($component, $langcode, $status);
}
elseif ($current_status == Lingotek::STATUS_EDITED && in_array($status, [
Lingotek::STATUS_CURRENT,
Lingotek::STATUS_PENDING,
])) {
$this
->setTargetStatus($component, $langcode, $status);
}
if ($status === Lingotek::STATUS_CANCELLED) {
$this
->setTargetStatus($component, $langcode, $status);
}
if ($status === Lingotek::STATUS_DISABLED) {
$this
->setTargetStatus($component, $langcode, $status);
}
}
}
}