function locale_languages_overview_form_submit in Drupal 6
Same name and namespace in other branches
- 7 modules/locale/locale.admin.inc \locale_languages_overview_form_submit()
Process language overview form submissions, updating existing languages.
Related topics
File
- includes/
locale.inc, line 102 - Administration functions for locale.module.
Code
function locale_languages_overview_form_submit($form, &$form_state) {
$languages = language_list();
$default = language_default();
$enabled_count = 0;
foreach ($languages as $langcode => $language) {
if ($form_state['values']['site_default'] == $langcode || $default->language == $langcode) {
// Automatically enable the default language and the language
// which was default previously (because we will not get the
// value from that disabled checkox).
$form_state['values']['enabled'][$langcode] = 1;
}
if ($form_state['values']['enabled'][$langcode]) {
$enabled_count++;
$language->enabled = 1;
}
else {
$language->enabled = 0;
}
$language->weight = $form_state['values']['weight'][$langcode];
db_query("UPDATE {languages} SET enabled = %d, weight = %d WHERE language = '%s'", $language->enabled, $language->weight, $langcode);
$languages[$langcode] = $language;
}
drupal_set_message(t('Configuration saved.'));
variable_set('language_default', $languages[$form_state['values']['site_default']]);
variable_set('language_count', $enabled_count);
// Changing the language settings impacts the interface.
cache_clear_all('*', 'cache_page', TRUE);
$form_state['redirect'] = 'admin/settings/language';
return;
}