You are here

function l10n_update_export_form in Localization update 7.2

Form constructor for the Gettext translation files export form.

See also

l10n_update_export_form_submit()

File

./l10n_update.bulk.inc, line 141
Mass import-export and batch import functionality for Gettext .po files.

Code

function l10n_update_export_form($form, &$form_state) {
  global $language;
  $languages = language_list();
  $language_options = array();
  foreach ($languages as $langcode => $language) {
    if ($langcode != 'en' || l10n_update_english()) {
      $language_options[$langcode] = $language->name;
    }
  }
  $language_default = language_default();
  $groups = module_invoke_all('locale', 'groups');
  if (empty($language_options)) {
    $form['langcode'] = array(
      '#type' => 'value',
      '#value' => $language->language,
    );
    $form['langcode_text'] = array(
      '#type' => 'item',
      '#title' => t('Language'),
      '#markup' => t('No language available. The export will only contain source strings.'),
    );
  }
  else {
    $form['langcode'] = array(
      '#type' => 'select',
      '#title' => t('Language'),
      '#options' => $language_options,
      '#default_value' => $language_default->id,
      '#empty_option' => t('Source text only, no translations'),
      '#empty_value' => $language->language,
    );
    $form['textgroup'] = array(
      '#type' => 'select',
      '#title' => t('Text group'),
      '#options' => $groups,
      '#default_value' => 'default',
    );
    $form['content_options'] = array(
      '#type' => 'details',
      '#title' => t('Export options'),
      '#collapsed' => TRUE,
      '#tree' => TRUE,
      '#states' => array(
        'invisible' => array(
          ':input[name="langcode"]' => array(
            'value' => $language->language,
          ),
        ),
      ),
    );
    $form['content_options']['not_customized'] = array(
      '#type' => 'checkbox',
      '#title' => t('Include non-customized translations'),
      '#default_value' => TRUE,
    );
    $form['content_options']['customized'] = array(
      '#type' => 'checkbox',
      '#title' => t('Include customized translations'),
      '#default_value' => TRUE,
    );
    $form['content_options']['not_translated'] = array(
      '#type' => 'checkbox',
      '#title' => t('Include untranslated text'),
      '#default_value' => TRUE,
    );
  }
  $form['actions'] = array(
    '#type' => 'actions',
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Export'),
  );
  return $form;
}