Contributions API

l10n_client_import_package_form

Definition

l10n_client_import_package_form(&$form_state)
contributions/l10n_client/l10n_client.module, line 268

Description

Page callback function to present a form to reimport a translation package.

See also

l10n_client_import_package_form_submit()

Related topics

Namesort iconDescription
Form builder functionsFunctions that build an abstract representation of a HTML form.

Code

<?php
function l10n_client_import_package_form(&$form_state) {
  // Get all languages, except English
  $names = locale_language_list('name', TRUE);
  unset($names['en']);

  if (!count($names)) {
    // This only works if there is any foreign language set up.
    drupal_set_message(t('No languages set up to reimport packages into.', 'warning'));
    return array();
  }
  
  $form = array();
  $form['reimport'] = array(
    '#type' => 'fieldset',
    '#title' => t('Reimport translation package'),
  );
  $form['reimport']['langcode'] = array(
    '#type' => 'radios',
    '#title' => t('Language package'),
    '#options' => $names,
    '#default_value' => array_shift(array_keys($names)),
    '#description' => t('Choose a language package to reimport translations from. All files of the package should be already uncompressed to the Drupal directories. All translation files will be imported for enabled modules and themes and will be imported to the built in interface textgroup.'),
  );
  $form['reimport']['cleanup'] = array(
    '#type' => 'checkbox',
    '#title' => t('Clean up database before reimport'),
    '#description' => t('If checked, all translations for the given language will be deleted from the database first, and you will loose all your customized translations and those not available in the files being imported. Use with extreme caution.')
  );
  $form['reimport']['submit'] = array('#type' => 'submit', '#value' => t('Reimport package'));
  return $form;
}
?>