You are here

protected function LingotekConfigManagementForm::formatTranslations in Lingotek Translation 8.2

Same name and namespace in other branches
  1. 8 src/Form/LingotekConfigManagementForm.php \Drupal\lingotek\Form\LingotekConfigManagementForm::formatTranslations()
  2. 4.0.x src/Form/LingotekConfigManagementForm.php \Drupal\lingotek\Form\LingotekConfigManagementForm::formatTranslations()
  3. 3.0.x src/Form/LingotekConfigManagementForm.php \Drupal\lingotek\Form\LingotekConfigManagementForm::formatTranslations()
  4. 3.1.x src/Form/LingotekConfigManagementForm.php \Drupal\lingotek\Form\LingotekConfigManagementForm::formatTranslations()
  5. 3.2.x src/Form/LingotekConfigManagementForm.php \Drupal\lingotek\Form\LingotekConfigManagementForm::formatTranslations()
  6. 3.3.x src/Form/LingotekConfigManagementForm.php \Drupal\lingotek\Form\LingotekConfigManagementForm::formatTranslations()
  7. 3.4.x src/Form/LingotekConfigManagementForm.php \Drupal\lingotek\Form\LingotekConfigManagementForm::formatTranslations()
  8. 3.5.x src/Form/LingotekConfigManagementForm.php \Drupal\lingotek\Form\LingotekConfigManagementForm::formatTranslations()
  9. 3.6.x src/Form/LingotekConfigManagementForm.php \Drupal\lingotek\Form\LingotekConfigManagementForm::formatTranslations()
  10. 3.7.x src/Form/LingotekConfigManagementForm.php \Drupal\lingotek\Form\LingotekConfigManagementForm::formatTranslations()
  11. 3.8.x src/Form/LingotekConfigManagementForm.php \Drupal\lingotek\Form\LingotekConfigManagementForm::formatTranslations()

Formats the translation statuses for display.

Parameters

\Drupal\config_translation\ConfigMapperInterface $mapper: The mapper.

array $translations: Pairs of language - status.

Return value

array A render array.

1 call to LingotekConfigManagementForm::formatTranslations()
LingotekConfigManagementForm::getTranslationsStatuses in src/Form/LingotekConfigManagementForm.php
Gets the translation status of an entity in a format ready to display.

File

src/Form/LingotekConfigManagementForm.php, line 1545

Class

LingotekConfigManagementForm
Form for bulk management of content.

Namespace

Drupal\lingotek\Form

Code

protected function formatTranslations(ConfigMapperInterface $mapper, 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($mapper, $data['status'], $langcode),
        'url' => $data['url'],
        'new_window' => $data['new_window'],
      ];
    }
  }
  return [
    'data' => [
      '#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' => [
        'languages' => $languages,
      ],
    ],
  ];
}