You are here

function i18ntaxonomy_translation_overview in Internationalization 6

Generate a tabular listing of translations for vocabularies.

1 call to i18ntaxonomy_translation_overview()
i18ntaxonomy_page_vocabulary in i18ntaxonomy/i18ntaxonomy.admin.inc
This is the callback for taxonomy translations.

File

i18ntaxonomy/i18ntaxonomy.admin.inc, line 140
Helper functions for taxonomy administration.

Code

function i18ntaxonomy_translation_overview($vid) {
  $vocabulary = taxonomy_vocabulary_load($vid);
  drupal_set_title(check_plain($vocabulary->name));
  $output = '';
  $languages = i18n_supported_languages();
  $header = array_merge($languages, array(
    t('Operations'),
  ));
  $links = array();
  $types = array();

  // Get terms/translations for this vocab.
  $result = db_query('SELECT * FROM {term_data} t WHERE vid = %d', $vocabulary->vid);
  $terms = $messages = array();
  while ($term = db_fetch_object($result)) {
    if ($term->trid && $term->language) {
      $terms[$term->trid][$term->language] = $term;
    }
  }

  // Reorder data for rows and languages.
  $rows = array();
  foreach ($terms as $trid => $terms) {
    $thisrow = array();
    foreach ($languages as $lang => $name) {
      if (array_key_exists($lang, $terms)) {
        $thisrow[] = l($terms[$lang]->name, 'taxonomy/term/' . $terms[$lang]->tid);
      }
      else {
        $thisrow[] = '--';
      }
    }
    $thisrow[] = l(t('edit'), "admin/content/taxonomy/{$vid}/translation/edit/{$trid}");
    $rows[] = $thisrow;
  }
  if ($rows) {
    $output .= theme('table', $header, $rows);
  }
  else {
    $messages[] = t('No translations defined for this vocabulary.');
  }
  $messages[] = l(t('Create new translation'), "admin/content/taxonomy/{$vid}/translation/edit/new");
  $output .= theme('item_list', $messages);
  return $output;
}