You are here

function l10n_client_translate_page in Localization client 5

Same name and namespace in other branches
  1. 6.2 l10n_client.module \l10n_client_translate_page()
  2. 6 l10n_client.module \l10n_client_translate_page()
  3. 7 l10n_client.module \l10n_client_translate_page()

Menu callback. Translation pages.

1 string reference to 'l10n_client_translate_page'
l10n_client_menu in ./l10n_client.module
Implementation of hook_menu().

File

./l10n_client.module, line 52
Localization client. Provides on-page translation editing.

Code

function l10n_client_translate_page($op = 'untranslated') {
  global $locale, $l10n_client_strings;
  $output = '';

  // Build query for strings
  $sql = "SELECT s.source, t.translation, t.locale FROM {locales_source} s ";
  switch ($op) {
    case 'translated':
      $sql .= " INNER JOIN {locales_target} t ON s.lid = t.lid";
      $sql .= " WHERE t.locale = '%s' AND t.translation != ''";
      break;
    case 'untranslated':
    default:
      $sql .= " LEFT JOIN {locales_target} t ON s.lid = t.lid";
      $sql .= " WHERE t.locale = '%s' AND (t.translation IS NULL OR t.translation = '')";
      break;
  }

  // Order alphabetically
  $sql .= ' ORDER BY s.source';
  $result = pager_query($sql, L10N_CLIENT_STRINGS, 0, NULL, $locale);
  while ($data = db_fetch_object($result)) {

    // Array to display as table
    $list[] = array(
      check_plain($data->source),
      check_plain($data->translation),
    );

    // Add to the list for the translation tool
    $l10n_client_strings[$data->source] = empty($data->translation) ? TRUE : $data->translation;
  }
  if (!empty($list)) {

    // We add a pager above and below content to make navigation easier
    $output .= theme('pager', NULL, L10N_CLIENT_STRINGS);
    $output .= theme('table', array(), $list);
    $output .= theme('pager', NULL, L10N_CLIENT_STRINGS);
  }
  else {
    $output .= t('No strings to translate');
  }
  return $output;
}