You are here

function locale_translate_overview_screen in Drupal 6

Same name and namespace in other branches
  1. 7 modules/locale/locale.admin.inc \locale_translate_overview_screen()

Overview screen for translations.

Related topics

1 string reference to 'locale_translate_overview_screen'
locale_menu in modules/locale/locale.module
Implementation of hook_menu().

File

includes/locale.inc, line 497
Administration functions for locale.module.

Code

function locale_translate_overview_screen() {
  $languages = language_list('language', TRUE);
  $groups = module_invoke_all('locale', 'groups');

  // Build headers with all groups in order.
  $headers = array_merge(array(
    t('Language'),
  ), array_values($groups));

  // Collect summaries of all source strings in all groups.
  $sums = db_query("SELECT COUNT(*) AS strings, textgroup FROM {locales_source} GROUP BY textgroup");
  $groupsums = array();
  while ($group = db_fetch_object($sums)) {
    $groupsums[$group->textgroup] = $group->strings;
  }

  // Set up overview table with default values, ensuring common order for values.
  $rows = array();
  foreach ($languages as $langcode => $language) {
    $rows[$langcode] = array(
      'name' => $langcode == 'en' ? t('English (built-in)') : t($language->name),
    );
    foreach ($groups as $group => $name) {
      $rows[$langcode][$group] = $langcode == 'en' ? t('n/a') : '0/' . (isset($groupsums[$group]) ? $groupsums[$group] : 0) . ' (0%)';
    }
  }

  // Languages with at least one record in the locale table.
  $translations = db_query("SELECT COUNT(*) AS translation, t.language, s.textgroup FROM {locales_source} s INNER JOIN {locales_target} t ON s.lid = t.lid GROUP BY textgroup, language");
  while ($data = db_fetch_object($translations)) {
    $ratio = !empty($groupsums[$data->textgroup]) && $data->translation > 0 ? round($data->translation / $groupsums[$data->textgroup] * 100.0, 2) : 0;
    $rows[$data->language][$data->textgroup] = $data->translation . '/' . $groupsums[$data->textgroup] . " ({$ratio}%)";
  }
  return theme('table', $headers, $rows);
}