You are here

protected function LingotekTargetTrait::getTargetStatusText in Lingotek Translation 3.8.x

Same name and namespace in other branches
  1. 4.0.x src/Element/LingotekTargetTrait.php \Drupal\lingotek\Element\LingotekTargetTrait::getTargetStatusText()
  2. 3.6.x src/Element/LingotekTargetTrait.php \Drupal\lingotek\Element\LingotekTargetTrait::getTargetStatusText()
  3. 3.7.x src/Element/LingotekTargetTrait.php \Drupal\lingotek\Element\LingotekTargetTrait::getTargetStatusText()

Get the target status label.

Parameters

string $status: The target status.

string $langcode: The language code.

bool|null $translation_exists: TRUE if translation exists.

Return value

string The source status human-friendly label.

4 calls to LingotekTargetTrait::getTargetStatusText()
LingotekTargetStatus::preRender in src/Element/LingotekTargetStatus.php
Calculates the url and status title and adds them to the render array.
LingotekTargetStatuses::getTranslationsStatuses in src/Element/LingotekTargetStatuses.php
Gets the translation status of an entity in a format ready to display.
LingotekTargetStatuses::getTranslationsStatusesForConfigMapper in src/Element/LingotekTargetStatuses.php
LingotekTargetStatuses::getTranslationsStatusesForUI in src/Element/LingotekTargetStatuses.php

File

src/Element/LingotekTargetTrait.php, line 273

Class

LingotekTargetTrait
Trait for lingotek_target_status and lingotek_target_statuses reuse.

Namespace

Drupal\lingotek\Element

Code

protected function getTargetStatusText($status, $langcode, $translation_exists = NULL) {
  $language = ConfigurableLanguage::load($langcode);
  switch ($status) {
    case Lingotek::STATUS_UNTRACKED:
      return $language
        ->label() . ' - ' . $this
        ->t('Translation exists, but it is not being tracked by Lingotek');
    case Lingotek::STATUS_REQUEST:
      return $language
        ->label() . ' - ' . $this
        ->t('Request translation');
    case Lingotek::STATUS_PENDING:
      return $language
        ->label() . ' - ' . $this
        ->t('In-progress');
    case Lingotek::STATUS_READY:
      return $language
        ->label() . ' - ' . $this
        ->t('Ready for Download');
    case Lingotek::STATUS_INTERMEDIATE:
      return $language
        ->label() . ' - ' . $this
        ->t('In-progress (interim translation downloaded)');
    case Lingotek::STATUS_CURRENT:
      return $language
        ->label() . ' - ' . $this
        ->t('Current');
    case Lingotek::STATUS_EDITED:
      return $language
        ->label() . ' - ' . $this
        ->t('Not current');
    case Lingotek::STATUS_ERROR:
      return $language
        ->label() . ' - ' . $this
        ->t('Error');
    case Lingotek::STATUS_CANCELLED:
      return $language
        ->label() . ' - ' . $this
        ->t('Cancelled by user');
    case Lingotek::STATUS_DELETED:
      if (!isset($translation_exists)) {
        return $language
          ->label() . ' - ' . $this
          ->t('This target was deleted in Lingotek.');
      }
      if ($translation_exists) {
        return $language
          ->label() . ' - ' . $this
          ->t('This target was deleted in Lingotek and the translation exists.');
      }
      return $language
        ->label() . ' - ' . $this
        ->t('This target was deleted in Lingotek and the translation does not exist.');
    case Lingotek::STATUS_ARCHIVED:
      if (!isset($translation_exists)) {
        return $language
          ->label() . ' - ' . $this
          ->t('This target was archived in Lingotek.');
      }
      if ($translation_exists) {
        return $language
          ->label() . ' - ' . $this
          ->t('This target was archived in Lingotek and the translation exists.');
      }
      return $language
        ->label() . ' - ' . $this
        ->t('This target was archived in Lingotek and the translation does not exist.');
    default:
      return $language
        ->label() . ' - ' . ucfirst(strtolower($status));
  }
}