On this page
function locale_form_language_admin_add_form_alter_submit
locale_form_language_admin_add_form_alter_submit($form, FormStateInterface $form_state)
Form submission handler for language_admin_add_form().
Set a batch for a newly-added language.
File
- core/modules/locale/locale.module, line 685
- Enables the translation of the user interface to languages other than English.
Code
function locale_form_language_admin_add_form_alter_submit($form, FormStateInterface $form_state) {
\Drupal::moduleHandler()->loadInclude('locale', 'fetch.inc');
$options = _locale_translation_default_update_options();
if ($form_state->isValueEmpty('predefined_langcode') || $form_state->getValue('predefined_langcode') == 'custom') {
$langcode = $form_state->getValue('langcode');
}
else {
$langcode = $form_state->getValue('predefined_langcode');
}
if (\Drupal::config('locale.settings')->get('translation.import_enabled')) {
// Download and import translations for the newly added language.
$batch = locale_translation_batch_update_build(array(), array($langcode), $options);
batch_set($batch);
}
// Create or update all configuration translations for this language. If we
// are adding English then we need to run this even if import is not enabled,
// because then we extract English sources from shipped configuration.
if (\Drupal::config('locale.settings')->get('translation.import_enabled') || $langcode == 'en') {
\Drupal::moduleHandler()->loadInclude('locale', 'bulk.inc');
if ($batch = locale_config_batch_update_components($options, array($langcode))) {
batch_set($batch);
}
}
}
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!locale!locale.module/function/locale_form_language_admin_add_form_alter_submit/8.1.x