Index: modules/locale/locale.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/locale/locale.module,v
retrieving revision 1.191
diff -u -r1.191 locale.module
--- modules/locale/locale.module	5 Sep 2007 08:42:01 -0000	1.191
+++ modules/locale/locale.module	7 Sep 2007 00:30:10 -0000
@@ -469,45 +469,6 @@
   }
 }
 
-/**
- * Finished callback of system page locale import batch.
- * Inform the user of translation files imported.
- */
-function _locale_batch_system_finished($success, $results) {
-  if ($success) {
-    drupal_set_message(format_plural(count($results), 'One translation file imported for the newly installed modules.', '@count translation files imported for the newly installed modules.'));
-  }
-}
-
-/**
- * Finished callback of language addition locale import batch.
- * Inform the user of translation files imported.
- */
-function _locale_batch_language_finished($success, $results) {
-  if ($success) {
-    drupal_set_message(format_plural(count($results), 'One translation file imported for the enabled modules.', '@count translation files imported for the enabled modules.'));
-  }
-}
-
-/**
- * Perform interface translation import as a batch step.
- *
- * @param $filepath
- *   Path to a file to import.
- * @param $results
- *   Contains a list of files imported.
- */
-function _locale_batch_import($filepath, &$context) {
-  include_once 'includes/locale.inc';
-  // The filename is either {langcode}.po or {prefix}.{langcode}.po, so
-  // we can extract the language code to use for the import from the end.
-  if (preg_match('!(/|\.)([^\.]+)\.po$!', $filepath, $langcode)) {
-    $file = (object) array('filename' => basename($filepath), 'filepath' => $filepath);
-    _locale_import_read_po('db-store', $file, LOCALE_IMPORT_KEEP, $langcode[2]);
-    $context['results'][] = $filepath;
-  }
-}
-
 // ---------------------------------------------------------------------------------
 // Language switcher block
 
Index: includes/batch.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/batch.inc,v
retrieving revision 1.11
diff -u -r1.11 batch.inc
--- includes/batch.inc	4 Sep 2007 21:10:45 -0000	1.11
+++ includes/batch.inc	7 Sep 2007 00:29:55 -0000
@@ -157,12 +157,20 @@
 function _batch_process() {
   $batch =& batch_get();
   $current_set =& _batch_current_set();
+  $set_changed = TRUE;
 
   if ($batch['progressive']) {
     timer_start('batch_processing');
   }
 
   while (!$current_set['success']) {
+    // If this is the first time we iterate this batch set in the current
+    // request, we check if it requires an additional file for functions
+    // definitions.
+    if ($set_changed && isset($current_set['file']) && is_file($current_set['file'])) {
+      include_once($current_set['file']);
+    }
+
     $finished = 1;
     $task_message = '';
     if ((list($function, $args) = reset($current_set['operations'])) && function_exists($function)) {
@@ -273,8 +281,14 @@
 
   // Execute the 'finished' callbacks.
   foreach ($batch['sets'] as $key => $batch_set) {
-    if (isset($batch_set['finished']) && function_exists($batch_set['finished'])) {
-      $batch_set['finished']($batch_set['success'], $batch_set['results'], $batch_set['operations']);
+    if (isset($batch_set['finished'])) {
+      // Check if the set requires an additional file for functions definitions.
+      if (isset($batch_set['file']) && is_file($batch_set['file'])) {
+        include_once($batch_set['file']);
+      }
+      if (function_exists($batch_set['finished'])) {
+        $batch_set['finished']($batch_set['success'], $batch_set['results'], $batch_set['operations']);
+      }
     }
   }
 
Index: includes/locale.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/locale.inc,v
retrieving revision 1.154
diff -u -r1.154 locale.inc
--- includes/locale.inc	4 Sep 2007 21:10:45 -0000	1.154
+++ includes/locale.inc	7 Sep 2007 00:30:07 -0000
@@ -2436,6 +2436,39 @@
 }
 
 /**
+ * Prepare a batch to run when installing modules or enabling themes.
+ * This batch will import translations for the newly added components
+ * in all the languages already set up on the site.
+ *
+ * @param $components
+ *   An array of component (theme and/or module) names to import
+ *   translations for.
+ * @param $finished
+ *   Optional finished callback for the batch.
+ */
+function locale_batch_by_component($components, $finished = '_locale_batch_system_finished') {
+  $files = array();
+  $languages = language_list('enabled');
+  unset($languages[1]['en']);
+  if (count($languages[1])) {
+    $language_list = join('|', array_keys($languages[1]));
+    // Collect all files to import for all $components.
+    $result = db_query("SELECT name, filename FROM {system} WHERE status = 1");
+    while ($component = db_fetch_object($result)) {
+      if (in_array($component->name, $components)) {
+        // Collect all files for this component in all enabled languages, named
+        // as $langcode.po or with names ending with $langcode.po. This allows
+        // for filenames like node-module.de.po to let translators use small
+        // files and be able to import in smaller chunks.
+        $files = array_merge($files, file_scan_directory(dirname($component->filename) .'/translations', '(^|\.)('. $language_list .')\.po$', array('.', '..', 'CVS'), 0, FALSE));
+      }
+    }
+    return _locale_batch_build($files, $finished);
+  }
+  return FALSE;
+}
+
+/**
  * Build a locale batch from an array of files.
  *
  * @param $files
@@ -2457,6 +2490,7 @@
         'title'         => $t('Importing interface translations'),
         'init_message'  => $t('Starting import'),
         'error_message' => $t('Error importing interface translations'),
+        'file'          => './includes/locale.inc',
       );
       if (isset($finished)) {
         $batch['finished'] = $finished;
@@ -2467,45 +2501,52 @@
 }
 
 /**
- * Batch callback invoked when installer import processing finishes.
- * Advance installer task to the finished screen.
+ * Perform interface translation import as a batch step.
+ *
+ * @param $filepath
+ *   Path to a file to import.
+ * @param $results
+ *   Contains a list of files imported.
  */
-function _locale_batch_installer_finished($success, $results) {
-  variable_set('install_task', 'finished');
+function _locale_batch_import($filepath, &$context) {
+  include_once 'includes/locale.inc';
+  // The filename is either {langcode}.po or {prefix}.{langcode}.po, so
+  // we can extract the language code to use for the import from the end.
+  if (preg_match('!(/|\.)([^\.]+)\.po$!', $filepath, $langcode)) {
+    $file = (object) array('filename' => basename($filepath), 'filepath' => $filepath);
+    _locale_import_read_po('db-store', $file, LOCALE_IMPORT_KEEP, $langcode[2]);
+    $context['results'][] = $filepath;
+  }
 }
 
 /**
- * Prepare a batch to run when installing modules or enabling themes.
- * This batch will import translations for the newly added components
- * in all the languages already set up on the site.
- *
- * @param $components
- *   An array of component (theme and/or module) names to import
- *   translations for.
- * @param $finished
- *   Optional finished callback for the batch.
+ * Finished callback of system page locale import batch.
+ * Inform the user of translation files imported.
  */
-function locale_batch_by_component($components, $finished = '_locale_batch_system_finished') {
-  $files = array();
-  $languages = language_list('enabled');
-  unset($languages[1]['en']);
-  if (count($languages[1])) {
-    $language_list = join('|', array_keys($languages[1]));
-    // Collect all files to import for all $components.
-    $result = db_query("SELECT name, filename FROM {system} WHERE status = 1");
-    while ($component = db_fetch_object($result)) {
-      if (in_array($component->name, $components)) {
-        // Collect all files for this component in all enabled languages, named
-        // as $langcode.po or with names ending with $langcode.po. This allows
-        // for filenames like node-module.de.po to let translators use small
-        // files and be able to import in smaller chunks.
-        $files = array_merge($files, file_scan_directory(dirname($component->filename) .'/translations', '(^|\.)('. $language_list .')\.po$', array('.', '..', 'CVS'), 0, FALSE));
-      }
-    }
-    return _locale_batch_build($files, $finished);
+function _locale_batch_system_finished($success, $results) {
+  if ($success) {
+    drupal_set_message(format_plural(count($results), 'One translation file imported for the newly installed modules.', '@count translation files imported for the newly installed modules.'));
   }
-  return FALSE;
 }
+
+/**
+ * Finished callback of language addition locale import batch.
+ * Inform the user of translation files imported.
+ */
+function _locale_batch_language_finished($success, $results) {
+  if ($success) {
+    drupal_set_message(format_plural(count($results), 'One translation file imported for the enabled modules.', '@count translation files imported for the enabled modules.'));
+  }
+}
+
+/**
+ * Finished callbackof installer language import.
+ * Advance installer task to the finished screen.
+ */
+function _locale_batch_installer_finished($success, $results) {
+  variable_set('install_task', 'finished');
+}
+
 /**
  * @} End of "locale-autoimport"
  */
