1 locale.bulk.inc locale_translate_batch_import_files($langcode = NULL, $finish_feedback = FALSE)

Prepare a batch to import all translations.

@todo Integrate with update status to identify projects needed and integrate l10n_update functionality to feed in translation files alike. See http://drupal.org/node/1191488.

Parameters

$langcode: (optional) Language code to limit files being imported.

$finish_feedback: (optional) Whether to give feedback to the user when finished.

File

core/modules/locale/locale.bulk.inc, line 206
Mass import-export and batch import functionality for Gettext .po files.

Code

function locale_translate_batch_import_files($langcode = NULL, $finish_feedback = FALSE) {
  $directory = settings_get('locale_translate_file_directory', conf_path() . '/files/translations');
  $files = array();
  if (!empty($langcode)) {
    $langcodes = array($langcode);
  }
  else {
    // If langcode was not provided, make sure to only import files for the
    // languages we have enabled.
    $langcodes = array_keys(language_list());
  }
  foreach ($langcodes as $langcode) {
    $files = array_merge($files, file_scan_directory($directory, '!' . (!empty($langcode) ? '\.' . preg_quote($langcode, '!') : '') . '\.po$!', array('recurse' => FALSE)));
  }
  return locale_translate_batch_build($files, $finish_feedback);
}