You are here

function lingotek_get_target_status in Lingotek Translation 7.3

Same name and namespace in other branches
  1. 7.2 lingotek.dashboard.inc \lingotek_get_target_status()
  2. 7.4 lingotek.dashboard.inc \lingotek_get_target_status()

Get the status of the target given by locale

2 calls to lingotek_get_target_status()
lingotek_dashboard_command_ajax in ./lingotek.dashboard.inc
Ajax Command Processing for the Lingotek dashboard.
lingotek_get_dashboard_code in ./lingotek.dashboard.inc
Generates the code for the embedded Javascript dashboard.

File

./lingotek.dashboard.inc, line 310
Lingotek Dashboard.

Code

function lingotek_get_target_status($lingotek_locale = NULL) {
  $response = array();
  $target_languages = Lingotek::availableLanguageTargets();

  // If we get a parameter, only return that language.  Otherwise return all the codes (dont return the source language).
  if (!is_null($lingotek_locale)) {
    $drupal_language_code = Lingotek::convertLingotek2Drupal($lingotek_locale);
    $target_is_active = in_array($drupal_language_code, array_keys($target_languages));
    $edited = LingotekSync::getTargetCountByStatus(LingotekSync::STATUS_EDITED, $lingotek_locale);
    $pending = LingotekSync::getTargetCountByStatus(LingotekSync::STATUS_PENDING, $lingotek_locale);
    $current = LingotekSync::getTargetCountByStatus(LingotekSync::STATUS_CURRENT, $lingotek_locale);
    $total = $edited + $pending + $current;
    $response = array(
      'code' => $lingotek_locale,
      // Return this language code as the Lingotek language code.
      'dcode' => $drupal_language_code,
      'active' => $target_is_active,
      'docs' => $total,
      'pending' => $pending,
      'edited' => $edited,
      'current' => $current,
    );
  }
  else {

    // Otherwise Return a List of all the Active Languages
    foreach ($target_languages as $target) {
      $drupal_language_code = $target->language;
      $lingotek_locale = $target->lingotek_locale;

      //Lingotek::convertDrupal2Lingotek($drupal_language_code)
      $edited = LingotekSync::getTargetCountByStatus(LingotekSync::STATUS_EDITED, $lingotek_locale);
      $pending = LingotekSync::getTargetCountByStatus(LingotekSync::STATUS_PENDING, $lingotek_locale);
      $current = LingotekSync::getTargetCountByStatus(LingotekSync::STATUS_CURRENT, $lingotek_locale);
      $total = $edited + $pending + $current;
      $response[] = array(
        'code' => $lingotek_locale,
        // Return this language code as the Lingotek language code.
        'dcode' => $drupal_language_code,
        'active' => $target->lingotek_enabled,
        'docs' => $total,
        'pending' => $pending,
        'edited' => $edited,
        'current' => $current,
      );
    }

    // END:  foreach target language
  }

  // END:  Language List
  return $response;
}