function _l10n_update_batch_finished in Localization update 6
Same name and namespace in other branches
- 7 l10n_update.batch.inc \_l10n_update_batch_finished()
Batch finished callback: Set result message.
Parameters
$success: TRUE if batch succesfully completed.
$results: Batch results.
1 string reference to '_l10n_update_batch_finished'
- _l10n_update_create_batch in ./
l10n_update.batch.inc - Create batch stub for this module.
File
- ./
l10n_update.batch.inc, line 192
Code
function _l10n_update_batch_finished($success, $results) {
$totals = array();
// Sum of added, updated and deleted translations.
$total_skip = 0;
// Sum of skipped translations
$messages = array();
// User feedback messages.
$project_fail = $project_success = array();
// Project names of succesfull and failed imports.
$t = get_t();
if ($success) {
// Summarize results of added, updated, deleted and skiped translations.
// Added, updated and deleted are summarized per language to be displayed accordingly.
foreach ($results as $result) {
if (isset($result['fail'])) {
// Collect project names of the failed imports.
$project_fail[$result['file']->name] = $result['file']->name;
}
else {
$language = $result['language'];
// Initialize variables to prevent PHP Notices.
if (!isset($totals[$language])) {
$totals[$language] = array();
$totals[$language]['add'] = $totals[$language]['update'] = $totals[$language]['delete'] = 0;
}
// Summarize added, updated, deleted and skiped translations.
$totals[$language]['add'] += $result['add'];
$totals[$language]['update'] += $result['update'];
$totals[$language]['delete'] += $result['delete'];
$total_skip += $result['skip'];
// Collect project names of the succesfull imports.
$project_success[$result['file']->name] = $result['file']->name;
}
}
// Messages of succesfull translation update results.
if ($project_success) {
$messages[] = format_plural(count($project_success), 'One project updated: @projects.', '@count projects updated: @projects.', array(
'@projects' => implode(', ', $project_success),
));
$languages = language_list();
foreach ($totals as $language => $total) {
$messages[] = $t('%language translation strings added: !add, updated: !update, deleted: !delete.', array(
'%language' => $languages[$language]->name,
'!add' => $total['add'],
'!update' => $total['update'],
'!delete' => $total['delete'],
));
}
drupal_set_message(implode("<br />\n", $messages));
// Warning for disallowed HTML.
if ($total_skip) {
drupal_set_message(format_plural($total_skip, 'One translation string was skipped because it contains disallowed HTML.', '@count translation strings were skipped because they contain disallowed HTML.'), 'warning');
}
}
// Error for failed imports.
if ($project_fail) {
drupal_set_message(format_plural(count($project_fail), 'Translations of one project were not imported: @projects.', 'Translations of @count projects were not imported: @projects', array(
'@projects' => implode(', ', $project_fail),
)), 'error');
}
}
else {
drupal_set_message($t('Error importing translations.'), 'error');
}
}