On this page
function locale_batch_by_component
locale_batch_by_component($components, $finished = '_locale_batch_system_finished')
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
File
- includes/locale.inc, line 2283
- 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;
}
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/includes!locale.inc/function/locale_batch_by_component/7.x