You are here

function l10n_client_import_package_form_submit in Localization client 6

Submission handler for package reimport form.

See also

l10n_client_import_package_form()

File

./l10n_client.module, line 502
Localization client. Provides on-page translation editing.

Code

function l10n_client_import_package_form_submit($form, &$form_state) {
  if (!empty($form_state['values']['textgroups'])) {

    // Clean out all translations first if user asked to do that.
    $langcodes = array_keys(array_filter($form_state['values']['langcodes']));
    $textgroups = array_keys(array_filter($form_state['values']['textgroups']));
    if (!empty($textgroups)) {
      db_query("DELETE FROM {locales_target} WHERE language IN (" . db_placeholders($langcodes, 'varchar') . ") AND lid IN (SELECT lid FROM {locales_source} WHERE textgroup IN (" . db_placeholders($textgroups, 'varchar') . "))", array_merge($langcodes, $textgroups));

      // Also remove all source strings without translations.
      db_query("DELETE FROM {locales_source} WHERE lid NOT IN (SELECT lid FROM {locales_target})");
    }
  }

  // Set up and start batch for new imports.
  include_once 'includes/locale.inc';
  foreach (array_filter($form_state['values']['langcodes']) as $langcode) {
    if ($batch = locale_batch_by_language($langcode, '_locale_batch_language_finished')) {
      batch_set($batch);
    }
  }
  $form_state['redirect'] = 'admin/build/translate';
}