protected function LocaleSourcePluginUi::getTranslationData

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.

File

sources/locale/src/LocaleSourcePluginUi.php, line 127

Class

LocaleSourcePluginUi
Locale source plugin UI.

Namespace

Drupal\tmgmt_locale

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 ($this
      ->getLanguages() 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;
}