function locale_batch_by_component in Drupal 7
Same name and namespace in other branches
- 6 includes/locale.inc \locale_batch_by_component()
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.
Parameters
$components: An array of component (theme and/or module) names to import translations for.
$finished: Optional finished callback for the batch.
Related topics
1 call to locale_batch_by_component()
- locale_system_update in modules/
locale/ locale.module - Imports translations when new modules or themes are installed.
File
- includes/
locale.inc, line 2286 - Administration functions for locale.module.
Code
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");
foreach ($result as $component) {
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(
'recurse' => FALSE,
)));
}
}
return _locale_batch_build($files, $finished);
}
return FALSE;
}