function locale_languages_predefined_form_validate in Drupal 6
Same name and namespace in other branches
- 7 modules/locale/locale.admin.inc \locale_languages_predefined_form_validate()
Validate the language addition form.
Related topics
1 string reference to 'locale_languages_predefined_form_validate'
- locale_languages_custom_form in includes/
locale.inc - Custom language addition form.
File
- includes/
locale.inc, line 289 - Administration functions for locale.module.
Code
function locale_languages_predefined_form_validate($form, &$form_state) {
$langcode = $form_state['values']['langcode'];
if ($duplicate = db_result(db_query("SELECT COUNT(*) FROM {languages} WHERE language = '%s'", $langcode)) != 0) {
form_set_error('langcode', t('The language %language (%code) already exists.', array(
'%language' => $form_state['values']['name'],
'%code' => $langcode,
)));
}
if (!isset($form_state['values']['name'])) {
// Predefined language selection.
$predefined = _locale_get_predefined_list();
if (!isset($predefined[$langcode])) {
form_set_error('langcode', t('Invalid language code.'));
}
}
else {
// Reuse the editing form validation routine if we add a custom language.
locale_languages_edit_form_validate($form, $form_state);
}
}