Commit b93818ac authored by catch's avatar catch

Issue #1738374 by sxnc, Gábor Hojtsy: Provide a cue to enable the language...

Issue #1738374 by sxnc, Gábor Hojtsy: Provide a cue to enable the language switcher when adding a language.
parent 312e9afa
......@@ -199,7 +199,7 @@ function language_admin_add_form($form, &$form_state) {
),
),
'#validate' => array('language_admin_add_predefined_form_validate'),
'#submit' => array('language_admin_add_predefined_form_submit'),
'#submit' => array('language_admin_add_form_submit'),
);
$form['custom_language'] = array(
......@@ -215,7 +215,7 @@ function language_admin_add_form($form, &$form_state) {
'#type' => 'submit',
'#value' => t('Add custom language'),
'#validate' => array('language_admin_add_custom_form_validate'),
'#submit' => array('language_admin_add_custom_form_submit'),
'#submit' => array('language_admin_add_form_submit'),
);
return $form;
......@@ -325,34 +325,34 @@ function language_admin_add_custom_form_validate($form, &$form_state) {
}
/**
* Process the custom language addition form submission.
* Process the custom and predefined language addition form submission.
*/
function language_admin_add_custom_form_submit($form, &$form_state) {
$langcode = $form_state['values']['langcode'];
// Custom language form.
$language = (object) array(
'langcode' => $langcode,
'name' => $form_state['values']['name'],
'direction' => $form_state['values']['direction'],
);
language_save($language);
drupal_set_message(t('The language %language has been created and can now be used.', array('%language' => $form_state['values']['name'])));
$form_state['redirect'] = 'admin/config/regional/language';
}
/**
* Process the predefined language addition form submission.
*/
function language_admin_add_predefined_form_submit($form, &$form_state) {
// Predefined language selection.
function language_admin_add_form_submit($form, &$form_state) {
$langcode = $form_state['values']['predefined_langcode'];
include_once DRUPAL_ROOT . '/core/includes/standard.inc';
$predefined = standard_language_list();
$language = (object) array(
'langcode' => $langcode,
);
language_save($language);
drupal_set_message(t('The language %language has been created and can now be used.', array('%language' => t($predefined[$langcode][0]))));
if ($langcode == 'custom') {
$langcode = $form_state['values']['langcode'];
// Custom language form.
$language = (object) array(
'langcode' => $langcode,
'name' => $form_state['values']['name'],
'direction' => $form_state['values']['direction'],
);
}
else {
include_once DRUPAL_ROOT . '/core/includes/standard.inc';
$predefined = standard_language_list();
$language = (object) array(
'langcode' => $langcode,
);
}
// Save the language and inform the user that it happened.
$language = language_save($language);
drupal_set_message(t('The language %language has been created and can now be used.', array('%language' => $language->name)));
// Tell the user they have the option to add a language switcher block
// to their theme so they can switch between the languages.
drupal_set_message(t('Use one of the language switcher blocks to allow site visitors to switch between languages. You can enable these blocks on the <a href="@block-admin">block administration page</a>.', array('@block-admin' => 'admin/structure/block')));
$form_state['redirect'] = 'admin/config/regional/language';
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment