You are here

function locale_languages_predefined_form_submit in Drupal 7

Same name and namespace in other branches
  1. 6 includes/locale.inc \locale_languages_predefined_form_submit()

Process the language addition form submission.

Related topics

1 string reference to 'locale_languages_predefined_form_submit'
locale_languages_custom_form in modules/locale/locale.admin.inc
Custom language addition form.

File

modules/locale/locale.admin.inc, line 348
Administration functions for locale.module.

Code

function locale_languages_predefined_form_submit($form, &$form_state) {
  $langcode = $form_state['values']['langcode'];
  if (isset($form_state['values']['name'])) {

    // Custom language form.
    locale_add_language($langcode, $form_state['values']['name'], $form_state['values']['native'], $form_state['values']['direction'], $form_state['values']['domain'], $form_state['values']['prefix']);
    drupal_set_message(t('The language %language has been created and can now be used. More information is available on the <a href="@locale-help">help screen</a>.', array(
      '%language' => t($form_state['values']['name']),
      '@locale-help' => url('admin/help/locale'),
    )));
  }
  else {

    // Predefined language selection.
    include_once DRUPAL_ROOT . '/includes/iso.inc';
    $predefined = _locale_get_predefined_list();
    locale_add_language($langcode);
    drupal_set_message(t('The language %language has been created and can now be used. More information is available on the <a href="@locale-help">help screen</a>.', array(
      '%language' => t($predefined[$langcode][0]),
      '@locale-help' => url('admin/help/locale'),
    )));
  }

  // See if we have language files to import for the newly added
  // language, collect and import them.
  if ($batch = locale_batch_by_language($langcode, '_locale_batch_language_finished')) {
    batch_set($batch);
  }
  $form_state['redirect'] = 'admin/config/regional/language';
}