protected function LingotekManagementForm::formatTranslations in Lingotek Translation 8
Formats the translation statuses for display.
Parameters
array $translations: Pairs of language - status.
Return value
array A render array.
1 call to LingotekManagementForm::formatTranslations()
- LingotekManagementForm::getTranslationsStatuses in src/
Form/ LingotekManagementForm.php - Gets the translation status of an entity in a format ready to display.
File
- src/
Form/ LingotekManagementForm.php, line 1114 - Contains \Drupal\Lingotek\Form\LingotekManagementForm.
Class
- LingotekManagementForm
- Form for bulk management of content.
Namespace
Drupal\lingotek\FormCode
protected function formatTranslations($entity, array $translations) {
$languages = [];
foreach ($translations as $langcode => $data) {
if ($this->languageManager
->getLanguage($langcode)) {
$languages[] = [
'language' => strtoupper($langcode),
'status' => strtolower($data['status']),
'status_text' => $this
->getTargetStatusText($entity, $data['status'], $langcode),
'url' => $data['url'],
'new_window' => $data['new_window'],
];
}
}
return array(
'data' => array(
'#type' => 'inline_template',
'#template' => '{% for language in languages %}{% if language.url %}<a href="{{ language.url }}" {%if language.new_window%}target="_blank"{%endif%}{%else%}<span {%endif%} class="language-icon target-{{language.status}}" title="{{language.status_text}}">{{language.language}}{%if language.url%}</a>{%else%}</span>{%endif%}{% endfor %}',
'#context' => array(
'languages' => $languages,
),
),
);
}