You are here

function locale_batch_by_language in Drupal 6

Same name and namespace in other branches
  1. 7 includes/locale.inc \locale_batch_by_language()

Prepare a batch to import translations for all enabled modules in a given language.

Parameters

$langcode: Language code to import translations for.

$finished: Optional finished callback for the batch.

$skip: Array of component names to skip. Used in the installer for the second pass import, when most components are already imported.

Return value

A batch structure or FALSE if no files found.

Related topics

2 calls to locale_batch_by_language()
install_tasks in ./install.php
Tasks performed after the database is initialized.
locale_languages_predefined_form_submit in includes/locale.inc
Process the language addition form submission.

File

includes/locale.inc, line 2526
Administration functions for locale.module.

Code

function locale_batch_by_language($langcode, $finished = NULL, $skip = array()) {

  // Collect all files to import for all enabled modules and themes.
  $files = array();
  $components = array();
  $query = "SELECT name, filename FROM {system} WHERE status = 1";
  if (count($skip)) {
    $query .= " AND name NOT IN (" . db_placeholders($skip, 'varchar') . ")";
  }
  $result = db_query($query, $skip);
  while ($component = db_fetch_object($result)) {

    // Collect all files for all components, names 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', '(^|\\.)' . $langcode . '\\.po$', array(
      '.',
      '..',
      'CVS',
    ), 0, FALSE));
    $components[] = $component->name;
  }
  return _locale_batch_build($files, $finished, $components);
}