Index: install.php =================================================================== RCS file: /cvs/drupal/drupal/install.php,v retrieving revision 1.52 diff -u -p -r1.52 install.php --- install.php 17 May 2007 06:35:05 -0000 1.52 +++ install.php 21 May 2007 14:38:10 -0000 @@ -676,7 +676,7 @@ function install_tasks($profile, $task) // Enable installation language as default site language. locale_add_language($install_locale, NULL, NULL, NULL, NULL, NULL, 1, TRUE); // Collect files to import for this language. - $batch = locale_batch_installer($install_locale); + $batch = locale_batch_by_language($install_locale); if (!empty($batch)) { // Start a batch, switch to 'locale-batch' task. We need to // set the variable here, because batch_process() redirects. Index: includes/locale.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/locale.inc,v retrieving revision 1.127 diff -u -p -r1.127 locale.inc --- includes/locale.inc 21 May 2007 10:56:05 -0000 1.127 +++ includes/locale.inc 21 May 2007 14:38:11 -0000 @@ -289,6 +289,12 @@ function locale_languages_predefined_for locale_add_language($langcode); drupal_set_message(t('The language %language has been created and can now be used. More information is available on the help screen.', array('%language' => t($predefined[$langcode][0]), '@locale-help' => url('admin/help/locale')))); } + + // See if we have language files to import for the newly added + // language, collect and import them. + if ($batch = locale_batch_by_language($langcode, '_locale_batch_language_finished')) { + batch_set($batch); + } $form_state['redirect'] = 'admin/settings/language'; return; @@ -835,7 +841,7 @@ function locale_translate_delete($lid) { * @param $default * Optionall set this language to be the default. */ -function locale_add_language($langcode, $name = NULL, $native = NULL, $direction = LANGUAGE_LTR, $domain = '', $prefix = '', $enabled = FALSE, $default = FALSE) { +function locale_add_language($langcode, $name = NULL, $native = NULL, $direction = LANGUAGE_LTR, $domain = '', $prefix = '', $enabled = TRUE, $default = FALSE) { // Default prefix on language code. if (empty($prefix)) { $prefix = $langcode; @@ -2098,14 +2104,17 @@ function _locale_get_predefined_list() { */ /** - * Prepare a batch to use to import translations on install time. + * Prepare a batch to import translations for all enabled + * modules in a given language. * * @param $langcode * Language code to import translations for. + * @param $finished + * Optional finished callback for the batch. * @return * A batch structure or FALSE if no files found. */ -function locale_batch_installer($langcode) { +function locale_batch_by_language($langcode, $finished = '_locale_batch_installer_finished') { // Collect all files to import for all enabled modules and themes. $files = array(); @@ -2118,7 +2127,7 @@ function locale_batch_installer($langcod $files = array_merge($files, file_scan_directory(dirname($component->filename) .'/po/', '(^|\.)'. $langcode .'\.po$', array('.', '..', 'CVS'), 0, FALSE)); } - return _locale_batch_build($files, '_locale_batch_installer_finished'); + return _locale_batch_build($files, $finished); } /** @@ -2127,7 +2136,7 @@ function locale_batch_installer($langcod * @param $files * Array of files to import * @param $finished - * A finished callback to use for the batch + * Optional finished callback for the batch. * @return * A batch structure */ @@ -2168,8 +2177,10 @@ function _locale_batch_installer_finishe * @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_system($components) { +function locale_batch_by_component($components, $finished = '_locale_batch_system_finished') { $files = array(); $languages = language_list('enabled'); unset($languages[1]['en']); @@ -2186,7 +2197,7 @@ function locale_batch_system($components $files = array_merge($files, file_scan_directory(dirname($component->filename) .'/po/', '(^|\.)('. $language_list .')\.po$', array('.', '..', 'CVS'), 0, FALSE)); } } - return _locale_batch_build($files, '_locale_batch_system_finished'); + return _locale_batch_build($files, $finished); } return FALSE; } Index: modules/locale/locale.module =================================================================== RCS file: /cvs/drupal/drupal/modules/locale/locale.module,v retrieving revision 1.173 diff -u -p -r1.173 locale.module --- modules/locale/locale.module 21 May 2007 10:56:05 -0000 1.173 +++ modules/locale/locale.module 21 May 2007 14:38:12 -0000 @@ -437,7 +437,7 @@ function locale_language_list($field = ' */ function locale_system_update($components) { include_once 'includes/locale.inc'; - if ($batch = locale_batch_system($components)) { + if ($batch = locale_batch_by_component($components)) { batch_set($batch); } } @@ -453,6 +453,16 @@ function _locale_batch_system_finished($ } /** + * 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