You are here

function l10n_update_system_update in Localization update 7.2

Imports translations when new modules or themes are installed.

This function will start a batch to import translations for the added components.

Parameters

array $components: An array of arrays of component (theme and/or module) names to import translations for, indexed by type.

2 calls to l10n_update_system_update()
l10n_update_modules_enabled in ./l10n_update.module
Implements hook_modules_enabled().
l10n_update_themes_enabled in ./l10n_update.module
Implements hook_themes_enabled().

File

./l10n_update.module, line 508
Download translations from remote localization server.

Code

function l10n_update_system_update(array $components) {
  $components += array(
    'module' => array(),
    'theme' => array(),
  );
  $list = array_merge($components['module'], $components['theme']);

  // Skip running the translation imports if in the installer,
  // because it would break out of the installer flow. We have
  // built-in support for translation imports in the installer.
  if (!drupal_installation_attempted() && l10n_update_translatable_language_list() && variable_get('l10n_update_import_enabled', TRUE)) {
    module_load_include('compare.inc', 'l10n_update');

    // Update the list of translatable projects and start the import batch.
    // Only when new projects are added the update batch will be triggered. Not
    // each enabled module will introduce a new project. E.g. sub modules.
    $projects = array_keys(l10n_update_build_projects());
    if ($list = array_intersect($list, $projects)) {
      module_load_include('fetch.inc', 'l10n_update');

      // Get translation status of the projects, download and update
      // translations.
      $options = _l10n_update_default_update_options();
      $batch = l10n_update_batch_update_build($list, array(), $options);
      batch_set($batch);
    }
  }
}