Same name and namespace in other branches
  1. 7.x modules/locale/locale.admin.inc \locale_translate_import_form()

User interface for the translation import screen.

Related topics

1 string reference to 'locale_translate_import_form'
locale_menu in modules/locale/locale.module
Implementation of hook_menu().

File

includes/locale.inc, line 608
Administration functions for locale.module.

Code

function locale_translate_import_form() {

  // Get all languages, except English
  $names = locale_language_list('name', TRUE);
  unset($names['en']);
  if (!count($names)) {
    $languages = _locale_prepare_predefined_list();
    $default = array_shift(array_keys($languages));
  }
  else {
    $languages = array(
      t('Already added languages') => $names,
      t('Languages not yet added') => _locale_prepare_predefined_list(),
    );
    $default = array_shift(array_keys($names));
  }
  $form = array();
  $form['import'] = array(
    '#type' => 'fieldset',
    '#title' => t('Import translation'),
  );
  $form['import']['file'] = array(
    '#type' => 'file',
    '#title' => t('Language file'),
    '#size' => 50,
    '#description' => t('A Gettext Portable Object (<em>.po</em>) file.'),
  );
  $form['import']['langcode'] = array(
    '#type' => 'select',
    '#title' => t('Import into'),
    '#options' => $languages,
    '#default_value' => $default,
    '#description' => t('Choose the language you want to add strings into. If you choose a language which is not yet set up, it will be added.'),
  );
  $form['import']['group'] = array(
    '#type' => 'radios',
    '#title' => t('Text group'),
    '#default_value' => 'default',
    '#options' => module_invoke_all('locale', 'groups'),
    '#description' => t('Imported translations will be added to this text group.'),
  );
  $form['import']['mode'] = array(
    '#type' => 'radios',
    '#title' => t('Mode'),
    '#default_value' => LOCALE_IMPORT_KEEP,
    '#options' => array(
      LOCALE_IMPORT_OVERWRITE => t('Strings in the uploaded file replace existing ones, new ones are added'),
      LOCALE_IMPORT_KEEP => t('Existing strings are kept, only new strings are added'),
    ),
  );
  $form['import']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Import'),
  );
  $form['#attributes']['enctype'] = 'multipart/form-data';
  return $form;
}