You are here

function opigno_lms_install_import_translation in Opigno LMS 7

Installation step callback.

Parameters

array $install_state: An array of information about the current installation state.

Return value

array $batch Batch operations array.

File

./opigno_lms.profile, line 141
Enables modules and site configuration for a standard site installation. Provides a default API for Apps and modules to use. This will simplify the user experience.

Code

function opigno_lms_install_import_translation(&$install_state) {

  // Enable installation language as default site language.
  include_once DRUPAL_ROOT . '/includes/locale.inc';
  $install_locale = $install_state['parameters']['locale'];
  locale_add_language($install_locale, NULL, NULL, NULL, '', NULL, 1, TRUE);

  // Change the cache system (during installation, the default cache is DrupalFakeCache
  //  and the l10n_update v2.1 module needs a real cache system).
  $old_cache = variable_get('cache_class_cache');
  variable_set('cache_class_cache', 'DrupalDatabaseCache');

  // Fetch and batch the translations!
  module_load_include('fetch.inc', 'l10n_update');
  $options = _l10n_update_default_update_options();
  $last_checked = variable_get('l10n_update_last_check');
  if ($last_checked < REQUEST_TIME - L10N_UPDATE_STATUS_TTL) {
    l10n_update_clear_status();
    $batch = l10n_update_batch_update_build(array(), array(
      $install_locale,
    ), $options);
  }
  else {
    $batch = l10n_update_batch_fetch_build(array(), array(
      $install_locale,
    ), $options);
  }

  // Put back the default caching system at the end of the batch.
  $batch['operations'][] = array(
    'variable_set',
    array(
      'cache_class_cache',
      $old_cache,
    ),
  );
  return $batch;
}