You are here

function locale_add_language_form_validate in Drupal 4

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

Validate the language addition form.

File

includes/locale.inc, line 175
Admin-related functions for locale.module.

Code

function locale_add_language_form_validate($form_id, $form_values) {
  if ($duplicate = db_num_rows(db_query("SELECT locale FROM {locales_meta} WHERE locale = '%s'", $form_values['langcode'])) != 0) {
    form_set_error(t('The language %language (%code) already exists.', array(
      '%language' => theme('placeholder', check_plain($form_values['langname'])),
      '%code' => theme('placeholder', $form_values['langcode']),
    )));
  }
  if (!isset($form_values['langname'])) {
    $isocodes = _locale_get_iso639_list();
    if (!isset($isocodes[$form_values['langcode']])) {
      form_set_error('langcode', t('Invalid language code.'));
    }
  }
}