You are here

function drd_server_admin_update_translation in Drupal Remote Dashboard Server 7.2

Same name and namespace in other branches
  1. 7 drd_server.admin.inc \drd_server_admin_update_translation()

Function to update translations of the current domain.

Parameters

boolean $redirect: If TRUE, this function will perform a redirect using drupal_goto() instead of just returning after completion.

1 call to drd_server_admin_update_translation()
drd_server_domain_update_translation in ./drd_server.domain.inc
DRD Server Action to update all translations on the current domain.
1 string reference to 'drd_server_admin_update_translation'
drd_server_menu in ./drd_server.module
Implements hook_menu().

File

./drd_server.admin.inc, line 353
Provides functionality for configuring drd_server and to return blocks for the admin module.

Code

function drd_server_admin_update_translation($redirect = TRUE) {
  if (module_exists('l10n_update')) {
    set_time_limit(0);
    module_load_include('admin.inc', 'l10n_update');
    if (function_exists('l10n_update_language_list')) {

      // TODO: l10n_update version has a completely changed structure which needs a rewrite.
      $steps = array(
        t('Refresh information'),
        t('Update translations'),
      );
      foreach ($steps as $step) {
        $projects = l10n_update_get_projects();
        $languages = l10n_update_language_list('name');
        if ($languages) {
          $history = l10n_update_get_history();
          $available = l10n_update_available_releases();
          $updates = l10n_update_build_updates($history, $available);
          $form_state = array(
            'values' => array(
              'op' => $step,
              'mode' => variable_get('l10n_update_import_mode', LOCALE_IMPORT_KEEP),
              // Send the empty array so that all languages get updated.
              'languages' => array(),
              'updates' => $updates,
            ),
          );
          $form = array();
          l10n_update_admin_import_form_submit($form, $form_state);
        }
      }
      $batch =& batch_get();
      if ($batch && !isset($batch['current_set'])) {

        // Set progressive to FALSE if called from xmlrpc.php.
        $batch['progressive'] = $redirect;
        $batch['form_state'] = array(
          'rebuild' => FALSE,
          'programmed' => FALSE,
        );
        batch_process();
      }
    }
  }

  // Allow other modules as well to jump in with translation update routines.
  module_invoke_all('drd_server_update_translation');
  if ($redirect) {
    drupal_goto($_SERVER['HTTP_REFERER']);
  }
}