function _l10n_update_batch_import in Localization update 7
Same name and namespace in other branches
- 6 l10n_update.batch.inc \_l10n_update_batch_import()
Batch process: Import translation file.
This takes a file parameter or continues from previous batch which should have downloaded a file.
Parameters
$id: Batch id to identify batch results. Result of this batch function are stored in $context['result'] identified by this $id.
$file: File to be imported. If empty, the file will be taken from $context['results'].
$mode: Import mode. How to treat existing and modified translations.
$context: Batch context array.
2 string references to '_l10n_update_batch_import'
- l10n_update_batch_import in ./
l10n_update.batch.inc - Create a batch to just import files.
- l10n_update_batch_multiple in ./
l10n_update.batch.inc - Create a big batch for multiple projects and languages.
File
- ./
l10n_update.batch.inc, line 165 - Reusable API for creating and running l10n update batches.
Code
function _l10n_update_batch_import($id, $file, $mode, &$context) {
$t = get_t();
// The batch import is performed in two or three steps.
// If import is performed after file download the file details of the download
// are used which are stored in the $context['results'] array.
// If a locally stored file is imported, the file details are placed in $file.
if (empty($file) && isset($context['results'][$id]['file']) && !isset($context['results'][$id]['fail'])) {
$file = $context['results'][$id]['file'];
}
if ($file) {
// Create a result if none exists yet.
if (!isset($context['results'][$id])) {
$context['results'][$id] = array();
}
if ($import_result = l10n_update_source_import($file, $mode)) {
$context['message'] = $t('Imported: %name.', array(
'%name' => $file->filename,
));
$context['results'][$id] = array_merge((array) $context['results'][$id], $import_result, array(
'file' => $file,
));
}
else {
$context['results'][$id] = array_merge((array) $context['results'][$id], array(
'fail' => TRUE,
), array(
'file' => $file,
));
}
}
}