Index: active_translation.batch.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/active_translation/active_translation.batch.inc,v
retrieving revision 1.3
diff -u -p -r1.3 active_translation.batch.inc
--- active_translation.batch.inc	22 May 2008 23:10:56 -0000	1.3
+++ active_translation.batch.inc	1 Jun 2008 19:28:46 -0000
@@ -24,11 +24,15 @@ function _active_translation_batch_opera
     // Initiate multistep processing. Call language_list() and reset its cache.
     $context['sandbox']['languages'] = array_keys(language_list('language', TRUE));
     $context['sandbox']['progress'] = 0;
-    $context['sandbox']['current_translation'] = 0;
-    $context['sandbox']['max'] = db_result(db_query('SELECT COUNT(DISTINCT tnid) FROM {node} WHERE tnid <> 0'));
+    $context['sandbox']['current_translation'] = 1;
+    $context['sandbox']['max'] = db_result(db_query('SELECT COUNT(DISTINCT tnid) FROM {node} WHERE tnid > 0'));
 
-    // Remove all existing translation information.
-    db_query('DELETE FROM {active_translation}');
+    // Drop and recreate the database table to ensure the columns match the
+    // current list of languages. Clear the cache to get rid of any cached
+    // schema info.
+    drupal_uninstall_schema('active_translation');
+    drupal_get_schema('active_translation', TRUE);
+    drupal_install_schema('active_translation');
 
     // Insert records for language neutral and untranslated nodes.
     $fields = $values = array();
@@ -41,13 +45,12 @@ function _active_translation_batch_opera
   }
 
   // Process the next set of translations.
-  $limit = 10;
-  $result = db_query_range("SELECT DISTINCT tnid FROM {node} WHERE tnid > %d AND tnid <> 0 ORDER BY tnid ASC", $context['sandbox']['current_translation'], 0, $limit);
+  $limit = 20;
+  $result = db_query_range("SELECT DISTINCT tnid FROM {node} WHERE tnid > %d ORDER BY tnid ASC", $context['sandbox']['current_translation'], 0, $limit);
   while ($row = db_fetch_object($result)) {
     $node = node_load($row->tnid);
     $translation = active_translation_recompute($node);
     drupal_write_record('active_translation', $translation);
-
     $context['sandbox']['progress']++;
     $context['sandbox']['current_translation'] = $row->tnid;
   }
Index: active_translation.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/active_translation/active_translation.install,v
retrieving revision 1.3
diff -u -p -r1.3 active_translation.install
--- active_translation.install	22 May 2008 23:10:56 -0000	1.3
+++ active_translation.install	1 Jun 2008 19:28:46 -0000
@@ -5,24 +5,23 @@
  * Implementation of hook_install().
  */
 function active_translation_install() {
-  drupal_install_schema('active_translation');
+  // We don't do any schema installation here, it happens in
+  // _active_translation_batch_operation().
 }
 
 /**
- * Implementation of hook_uninstall().
+ * Implementation of hook_enable().
  */
-function active_translation_uninstall() {
-  drupal_uninstall_schema('active_translation');
+function active_translation_enable() {
+  require_once drupal_get_path('module', 'active_translation') .'/active_translation.batch.inc';
+  batch_set(active_translation_build_batch_all());
 }
 
 /**
- * Implementation of hook_enable().
+ * Implementation of hook_disable().
  */
-function active_translation_enable() {
-  require_once drupal_get_path('module', 'active_translation') .'/active_translation.batch.inc';
-  if ($batch = active_translation_build_batch_all()) {
-    batch_set($batch);
-  }
+function active_translation_disable() {
+  drupal_uninstall_schema('active_translation');
 }
 
 /**
Index: active_translation.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/active_translation/active_translation.module,v
retrieving revision 1.3
diff -u -p -r1.3 active_translation.module
--- active_translation.module	22 May 2008 23:10:56 -0000	1.3
+++ active_translation.module	1 Jun 2008 19:28:46 -0000
@@ -119,10 +119,13 @@ function active_translation_nodeapi_upda
 
 function active_translation_nodeapi_delete($node) {
   if (!empty($node->tnid) && $node->nid != $node->tnid) {
+    // Recomputing for the node will load the record for the node's tnid.
     $translation = active_translation_recompute($node);
     drupal_write_record('active_translation', $translation, array('atid'));
   }
   else {
+    // TODO: I'm not really sure this is correct... Does deleting the original
+    // remove all the translations?
     db_query('DELETE FROM {active_translation} WHERE atid = %d', array($node->nid));
   }
 }
@@ -266,17 +269,9 @@ function active_translation_form_alter(&
  * active translation table in case languages are added or removed.
  */
 function active_translation_rebuild_on_submit() {
-  // This is the quick and dirty way of getting the table to match the new list
-  // of languages. Just drop it, then recreate it from the newly saved
-  // languages setting.
-  cache_clear_all();
-  drupal_uninstall_schema('active_translation');
-  drupal_install_schema('active_translation');
-
   // Now build a batch to update the table.
   require_once drupal_get_path('module', 'active_translation') .'/active_translation.batch.inc';
-  $batch = active_translation_build_batch_all();
-  batch_set($batch);
+  batch_set(active_translation_build_batch_all());
 }
 
 /**
