protected function LingotekTargetStatuses::getTranslationsStatusesForUI in Lingotek Translation 3.2.x
Same name and namespace in other branches
- 4.0.x src/Element/LingotekTargetStatuses.php \Drupal\lingotek\Element\LingotekTargetStatuses::getTranslationsStatusesForUI()
- 3.3.x src/Element/LingotekTargetStatuses.php \Drupal\lingotek\Element\LingotekTargetStatuses::getTranslationsStatusesForUI()
- 3.4.x src/Element/LingotekTargetStatuses.php \Drupal\lingotek\Element\LingotekTargetStatuses::getTranslationsStatusesForUI()
- 3.5.x src/Element/LingotekTargetStatuses.php \Drupal\lingotek\Element\LingotekTargetStatuses::getTranslationsStatusesForUI()
- 3.6.x src/Element/LingotekTargetStatuses.php \Drupal\lingotek\Element\LingotekTargetStatuses::getTranslationsStatusesForUI()
- 3.7.x src/Element/LingotekTargetStatuses.php \Drupal\lingotek\Element\LingotekTargetStatuses::getTranslationsStatusesForUI()
- 3.8.x src/Element/LingotekTargetStatuses.php \Drupal\lingotek\Element\LingotekTargetStatuses::getTranslationsStatusesForUI()
1 call to LingotekTargetStatuses::getTranslationsStatusesForUI()
- LingotekTargetStatuses::preRender in src/
Element/ LingotekTargetStatuses.php - Calculates the url and status title and adds them to the render array.
File
- src/
Element/ LingotekTargetStatuses.php, line 127
Class
- LingotekTargetStatuses
- Provides a Lingotek target status element.
Namespace
Drupal\lingotek\ElementCode
protected function getTranslationsStatusesForUI($component, $source_langcode, array $statuses) {
$translations = [];
$languages = \Drupal::languageManager()
->getLanguages();
$languages = array_filter($languages, function (LanguageInterface $language) {
$configLanguage = ConfigurableLanguage::load($language
->getId());
return \Drupal::service('lingotek.configuration')
->isLanguageEnabled($configLanguage);
});
foreach ($statuses as $langcode => $status) {
if ($langcode !== $source_langcode && array_key_exists($langcode, $languages)) {
// We may have an existing translation already.
$translations[$langcode] = [
'status' => $status,
'url' => $this
->getTargetActionUrlForUI($component, $status, $langcode),
'new_window' => in_array($status, [
Lingotek::STATUS_CURRENT,
Lingotek::STATUS_INTERMEDIATE,
Lingotek::STATUS_EDITED,
]),
];
}
array_walk($languages, function ($language, $langcode) use ($component, &$translations) {
if (!isset($translations[$langcode]) && $langcode !== 'en') {
$translations[$langcode] = [
'status' => Lingotek::STATUS_REQUEST,
'url' => $this
->getTargetActionUrlForUI($component, Lingotek::STATUS_REQUEST, $langcode),
'new_window' => FALSE,
];
}
});
}
ksort($translations);
foreach ($translations as $langcode => &$translation) {
$translation['status_text'] = $this
->getTargetStatusText($translation['status'], $langcode);
$translation['language'] = $langcode;
}
return $translations;
}