You are here

protected function TMGMTLocaleSourceUIController::getTranslationData in Translation Management Tool 7

Helper function to create translation data list for the sources page list.

Parameters

array $strings: Result of the search query returned by tmgmt_i18n_string_get_strings().

string $type: I18n object type.

Return value

array Structured array with translation data.

1 call to TMGMTLocaleSourceUIController::getTranslationData()
TMGMTLocaleSourceUIController::overviewForm in sources/locale/tmgmt_locale.ui.inc
Implements TMGMTSourceUIControllerInterface::overviewForm().

File

sources/locale/tmgmt_locale.ui.inc, line 125
Provides the I18nString source controller.

Class

TMGMTLocaleSourceUIController
Class TMGMTI18nStringDefaultSourceUIController

Code

protected function getTranslationData($strings, $type) {
  $objects = array();

  // Source language of locale strings is always english.
  $source_language = 'en';
  foreach ($strings as $string) {
    $id = $string->lid;

    // Get existing translations and current job items for the entity
    // to determine translation statuses
    $current_job_items = tmgmt_job_item_load_latest('locale', $type, $id, $source_language);
    $objects[$id] = array(
      'id' => $id,
      'object' => $string,
    );

    // Load entity translation specific data.
    foreach (language_list() as $langcode => $language) {
      $translation_status = 'current';
      if ($langcode == $source_language) {
        $translation_status = 'original';
      }
      elseif ($string->{$langcode} === NULL) {
        $translation_status = 'missing';
      }
      $objects[$id]['current_job_items'][$langcode] = isset($current_job_items[$langcode]) ? $current_job_items[$langcode] : NULL;
      $objects[$id]['translation_statuses'][$langcode] = $translation_status;
    }
  }
  return $objects;
}