Commit adb7d50b authored by Andrey Nuzhdov's avatar Andrey Nuzhdov
Browse files

source code base moved to 1.03 version



Signed-off-by: default avatarAndrewAnswer <andrew@answer.name>
parent 1748d48f
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ function _live_translation_report() {
  $status         = _live_translation_status();
  $import_status  = variable_get('live_translation_import_status', array());
  $import_time    = variable_get('live_translation_import_time', array());
  $untranslated   = variable_get('live_translation_update_untranslated', array());
  $data           = array();

  foreach ($languages[1] as $langcode => $language) {
@@ -42,6 +43,7 @@ function _live_translation_report() {
        'status'  => $status[$langcode][$mod],
        'strings' => isset($import_status[$langcode][$mod]) ? $import_status[$langcode][$mod] : 0,
        'time'    => isset($import_time[$langcode][$mod]) ? $import_time[$langcode][$mod] : 0,
        'un'      => isset($untranslated[$langcode][$mod]) ? $untranslated[$langcode][$mod] : '-',
      );
    }
  }
@@ -88,7 +90,8 @@ function theme_live_translation_report($data) {
    LIVE_TRANSLATION_STATUS_UNKNOWN => array('name' => t('Unknown'),                                  'class' => 'warning'),
    LIVE_TRANSLATION_STATUS_OUTDATE => array('name' => '',                                            'class' => 'error'),
    LIVE_TRANSLATION_STATUS_OK      => array('name' => t('Ok'),                                       'class' => 'ok'),
    LIVE_TRANSLATION_STATUS_INVALID => array('name' => t('Translation not available on server yet'),  'class' => ''),
    LIVE_TRANSLATION_STATUS_PROJECT => array('name' => t('Project not available on server'),          'class' => ''),
    LIVE_TRANSLATION_STATUS_VERSION => array('name' => t('Project version not available on server'),  'class' => ''),
  );
  foreach ($data as $langcode => $language) {
    $rows = array();
@@ -110,7 +113,8 @@ function theme_live_translation_report($data) {
        'data'  => array(
          $module['name'],
          $status,
          ($module['status'] == LIVE_TRANSLATION_STATUS_INVALID) ? '-' : format_date($module['time'], 'small')
          $module['un'],
          (($module['status'] == LIVE_TRANSLATION_STATUS_INVALID) or $module['time'] == 0) ? '-' : format_date($module['time'], 'small')
        ),
        'class' => $statuses[$module['status']]['class']
      );
@@ -120,7 +124,7 @@ function theme_live_translation_report($data) {
      '#collapsed'    => $collapsed,
      '#collapsible'  => TRUE,
      '#title'        => $language,
      '#value'        => theme('table', array(t('Module'), t('Status'), t('Last update')), $rows, array('class' => 'update'))
      '#value'        => theme('table', array(t('Module'), t('Status'), t('Untranslated'), t('Last update')), $rows, array('class' => 'update'))
    ));
  }

+27 −12
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ function _live_translation_status($single_value = NULL) {
      if ($langcode == 'en') {
        continue;
      }

      foreach ($modules as $mod) {
        if (!isset($update_time[$langcode][$mod]) or $update_time[$langcode][$mod] < $time) {
          $result[$langcode][$mod] = LIVE_TRANSLATION_STATUS_UNKNOWN;
@@ -42,8 +43,11 @@ function _live_translation_status($single_value = NULL) {
          $result[$langcode][$mod] = LIVE_TRANSLATION_STATUS_OUTDATE;
          $result_single = ($result_single == LIVE_TRANSLATION_STATUS_OK) ? LIVE_TRANSLATION_STATUS_OUTDATE : LIVE_TRANSLATION_STATUS_OK;
        }
        elseif (!empty($import_status[$langcode][$mod]) and $import_status[$langcode][$mod] < 0) {
          $result[$langcode][$mod] = LIVE_TRANSLATION_STATUS_INVALID;
        elseif (!empty($import_status[$langcode][$mod]) and $import_status[$langcode][$mod] == -1) {
          $result[$langcode][$mod] = LIVE_TRANSLATION_STATUS_PROJECT;
        }
        elseif (!empty($import_status[$langcode][$mod]) and $import_status[$langcode][$mod] == -2) {
          $result[$langcode][$mod] = LIVE_TRANSLATION_STATUS_VERSION;
        }
        else {
          $result[$langcode][$mod] = LIVE_TRANSLATION_STATUS_OK;
@@ -72,22 +76,34 @@ function _live_translation_servers($langcode) {
  switch ($langcode) {
    case 'am':
      return 'http://www.drupal.am';
    case 'id':
      return 'http://drupal.web.id';
    case 'be': // Belarussian
      return 'http://drupaler.ru';
    case 'bg': // Bulgarian
      return 'http://drupaler.ru';
    case 'cat':
      return 'http://drupal.cat';
    case 'cz':
      return 'http://l10n.drupal.cz';
    case 'dk':
      return 'http://drupal.l10n.dk';
    case 'be':
      return 'http://l10n.krimson.be';
    case 'es': // Spanish
      return 'http://l10n.drupal.org.es';
    case 'et': // Estonian
      return 'http://drupaler.ru';
    case 'fr': // French
      return 'http://l10n.drupalfr.org';
    case 'gr': // Greek
      return 'http://l10n.mydrupal.gr';
    case 'hu': // Hungarian
      return 'http://forditas.mindworks.hu';
    case 'id':
      return 'http://drupal.web.id';
    case 'in':
      return 'http://l10n.kashipur.in';
    case 'it':
      return 'http://l10n.drupalitalia.org';
    case 'kk': // Kazakh
      return 'http://drupaler.ru';
    case 'lv': // Latvian
      return 'http://l10n.drupal.lv';
    case 'no': // Norwegian
@@ -101,15 +117,17 @@ function _live_translation_servers($langcode) {
    case 'ro': // Romanian
      return 'http://l10n.drupal.zetnet.ro';
    case 'ru': // Russian
      return 'http://www.drupaler.ru';
      return 'http://drupaler.ru';
    case 'sk': // Slovakian
      return 'http://www.fem.uniag.sk/drupal-l10n-server';
    case 'es': // Spanish
      return 'http://l10n.drupal.org.es';
    case 'sr': // Serbian
      return 'http://drupaler.ru';
    case 'th': // Thai
      return 'http://l10n.drupal.in.th';
    case 'tr':
      return 'http://l10n.drupaltr.org';
    case 'uk': // Ukrainian
      return 'http://drupaler.ru';
    case 'vi': // Vietnan
      return 'http://vietcoop.net';
    default:
@@ -120,12 +138,9 @@ function _live_translation_servers($langcode) {
// Bengali team  http://www.mat3impex.com/bengali-drupal-l10n-server/
// Croatian  http://prijevod.drupalhr.org/
// Filipino team   http://pili.pin.as/translations/
// French team   http://l10n.drupalfr.org/
// Hebrew team   http://l10n.avramzon.net/
// Italian team  http://l10n.drupalitalia.org/
// Persian/Farsi   http://l10n.farzanbeh.com/
// Punjabi   http://kitchen.satluj.com/
// Russian, Belarusian, Bulgarian, Estonian, Ukrainian, Serbian  http://www.drupaler.ru/
// Scots team  http://scots.freso.dk/
// Simplified Chinese team   http://drupalchina.org/hanhua/
// Slovenian team  http://drupal.internetstoritve.com/
+26 −0
Original line number Diff line number Diff line
@@ -11,4 +11,30 @@ function live_translation_uninstall() {
  variable_del('live_translation_import_status');
  variable_del('live_translation_import_time');
  variable_del('live_translation_update_time');
  variable_del('live_translation_update_untranslated');
}

/**
 * Implementation of hook_requirements().
 */
function live_translation_requirements($phase) {
  if ($phase == 'runtime') {
    module_load_include('inc', 'live_translation');
    $requirements['live_translation']['title']        = t('Translation updates');
    switch (_live_translation_status(TRUE)) {
      case LIVE_TRANSLATION_STATUS_OUTDATE:
        $requirements['live_translation']['value']        = t('New translations available');
        $requirements['live_translation']['severity']     = REQUIREMENT_ERROR;
        $requirements['live_translation']['description']  = t('There are new strings translated on the translation servers. Go to !translation_status_page.', array('!translation_status_page' => l('translation status page', 'admin/reports/live-translation')));
        break;
      case LIVE_TRANSLATION_STATUS_UNKNOWN:
        $requirements['live_translation']['value']        = t('No update data available');
        $requirements['live_translation']['severity']     = REQUIREMENT_WARNING;
        $requirements['live_translation']['description']  = t('There is a long time you do not check the translation status with the server. Configure cron or !check_it_now.', array('!check_it_now' => l('check it now', 'admin/reports/live-translation/update')));
        break;
      default:
        $requirements['live_translation']['value']        = t('Up to date');
    }
    return $requirements;
  }
}
+5 −27
Original line number Diff line number Diff line
@@ -14,7 +14,8 @@ DEFINE('LIVE_TRANSLATION_LIMIT', 60*60*24*2);
DEFINE('LIVE_TRANSLATION_STATUS_UNKNOWN', 0);
DEFINE('LIVE_TRANSLATION_STATUS_OUTDATE', 1);
DEFINE('LIVE_TRANSLATION_STATUS_OK',      2);
DEFINE('LIVE_TRANSLATION_STATUS_INVALID', 3);
DEFINE('LIVE_TRANSLATION_STATUS_PROJECT', 3);
DEFINE('LIVE_TRANSLATION_STATUS_VERSION', 4);

// Translation server URL (defined by Live Translation - Server module)
DEFINE('LIVE_TRANSLATION_SERVER_URL', 'admin/live-translation/export');
@@ -25,7 +26,7 @@ DEFINE('LIVE_TRANSLATION_SERVER_URL', 'admin/live-translation/export');
function live_translation_cron() {
  module_load_include('update.inc', 'live_translation');
  if (_live_translation_status(TRUE) <= LIVE_TRANSLATION_STATUS_OUTDATE) {
    _live_translation_update();
    _live_translation_update(TRUE);
  }
}

@@ -35,12 +36,14 @@ function live_translation_cron() {
function live_translation_menu() {
  $items['admin/reports/live-translation'] = array(
    'access arguments'  => array('update translations'),
    'description'       => 'Get a status report about available translations for your installed modules and theme',
    'file'              => 'live_translation.admin.inc',
    'page callback'     => '_live_translation_report',
    'title'             => 'Available translations',
  );
  $items['admin/settings/live-translation'] = array(
    'access arguments'  => array('update translations'),
    'description'       => 'Set the translation server URLs',
    'file'              => 'live_translation.admin.inc',
    'page callback'     => 'drupal_get_form',
    'page arguments'    => array('_live_translation_settings'),
@@ -56,31 +59,6 @@ function live_translation_perm() {
  return array('update translations');
}

/**
 * Implementation of hook_requirements().
 */
function live_translation_requirements($phase) {
  if ($phase == 'runtime') {
    module_load_include('inc', 'live_translation');
    $requirements['live_translation']['title']        = t('Translation updates');
    switch (_live_translation_status(TRUE)) {
      case LIVE_TRANSLATION_STATUS_OUTDATE:
        $requirements['live_translation']['value']        = t('New translations available');
        $requirements['live_translation']['severity']     = REQUIREMENT_ERROR;
        $requirements['live_translation']['description']  = t('There are new strings translated on the translation servers. Go to <a href="admin/reports/live-translation">translation status page</a>.');
        break;
      case LIVE_TRANSLATION_STATUS_UNKNOWN:
        $requirements['live_translation']['value']        = t('No update data available');
        $requirements['live_translation']['severity']     = REQUIREMENT_WARNING;
        $requirements['live_translation']['description']  = t('There is a long time you do not check the translation status with the server. Configure cron or <a href="/admin/reports/live-translation/update">check it now</a>.');
        break;
      default:
        $requirements['live_translation']['value']        = t('Up to date');
    }
    return $requirements;
  }
}

/**
 * Implementation of hook_theme().
 */
+22 −5
Original line number Diff line number Diff line
@@ -78,7 +78,6 @@ function _live_translation_import($module, $langcode) {
    $file_obj->filename = $filename;
    if ($ret = _locale_import_po($file_obj, $langcode, $mode, $group) == FALSE) {
      $message  = t('The translation import of %filename failed.', array('%filename' => $filename));
      dpm($file_url);
    }
    else {
      $message  = t('The translation import of %filename was a sucess.', array('%filename' => $filename));
@@ -97,13 +96,16 @@ function _live_translation_import($module, $langcode) {
  // Display any error message
  if (isset($message)) {
    drupal_set_message($message, isset($ok) ? 'ok' : 'error');
    watchdog('live_translation', $message,  isset($ok) ? WATCHDOG_NOTICE : WATCHDOG_ERROR);
    watchdog('live_translation', $message,  NULL, isset($ok) ? WATCHDOG_NOTICE : WATCHDOG_ERROR);
  }

  // Delete the file
  if (empty($no_file)) {
    unlink($file);
  }

  // Go to the report page
  drupal_goto('admin/reports/live-translation');
}

/**
@@ -139,22 +141,37 @@ function _live_translation_update($return = FALSE) {
    // Save the tokens on DB for further use. But in case
    // of error, show a message
    if (xmlrpc_error()) {
      watchdog('live_translation_update', xmlrpc_error_msg(), array(), WATCHDOG_ERROR);
      watchdog('live_translation', xmlrpc_error_msg(), NULL, WATCHDOG_ERROR);
      drupal_set_message(xmlrpc_error_msg(), 'error');
    }
    else {
      $untranslated   = variable_get('live_translation_update_untranslated', array());
      $update_time    = variable_get('live_translation_update_time', array());
      watchdog('live_translation', 'Translation status updated to !langname', array('!langname' => $language->native), WATCHDOG_ERROR);
      drupal_set_message(t('Translation status updated to !langname', array('!langname' => $language->native)));

      foreach ($modules as $mod => $module) {
        $update_time[$langcode][$mod]   = time() + LIVE_TRANSLATION_LIMIT;
        if (is_array($pending_translations[$mod])) {
          $import_status[$langcode][$mod] = $pending_translations[$mod]['new'];
          $untranslated[$langcode][$mod]  = $pending_translations[$mod]['un'];
        }
        else {
          $import_status[$langcode][$mod] = $pending_translations[$mod];
          $untranslated[$langcode][$mod]  = 0;
        }
      }

      // Update the status
      variable_set('live_translation_update_time', $update_time);
      variable_set('live_translation_update_untranslated', $untranslated);
      variable_set('live_translation_import_status', $import_status);
    }
  }

  // Go to the report page
  if ($return) {
    return;
  }
  drupal_goto('admin/reports/live-translation');
}