diff --git a/core/includes/language.inc b/core/includes/language.inc index 66e1363..72eebef 100644 --- a/core/includes/language.inc +++ b/core/includes/language.inc @@ -208,36 +208,40 @@ function language_types_set(array $customized_language_types) { // information. drupal_static_reset('language_types_info'); drupal_static_reset('language_negotiation_info'); - $config_values = array(); + $customized = array(); $negotiation_info = language_negotiation_info(); $language_types_info = language_types_info(); foreach ($language_types_info as $type => $info) { $customized[$type] = in_array($type, $customized_language_types); - // Check if the language is locked. The configuration of a locked language - // type cannot be changed using the UI. + // Check if the language is unlocked. Only unlocked language types can have + // their customized setting changed using the UI. if (empty($info['locked'])) { - // The configuration of unlocked languages set using the UI. Save this - // data to the $customized array (stored in configuration). if ($customized[$type] && empty($info['fixed'])) { - // If the language is not configurable and there is no default language - // negotiation setting then provide one. + // If its customized (table is shown) and it has no default settings we + // give it some sane defaults that come from the language negotiation + // interface. $method_weights = array(LANGUAGE_NEGOTIATION_INTERFACE); $method_weights = array_flip($method_weights); language_negotiation_set($type, $method_weights); } } else { - // Locked languages don't allow changing their configurable state. + // The language type is locked. Locked language types do not get a + // customize checkbox in the UI. // Default language negotiation is stored in $info['fixed']. Locked - // language types with a default value are not configurable. Locked - // language types without a default value are always configurable. + // language types with a default value do not get a table. Locked + // language types without a default value always get a table. + // If default settings is empty, then customized is true, and the table + // should be shown. $customized[$type] = empty($info['fixed']); if (!empty($info['fixed'])) { - // Set the language negotiation for non configurable types to use the - // default settings stored in $info['fixed']. + // Language type is locked and has default settings and will never seen + // in the UI, for example URL language type. + + // The language type has default settings, stored in $info['fixed']. $method_weights = array(); foreach ($info['fixed'] as $weight => $method_id) { if (isset($negotiation_info[$method_id])) { diff --git a/core/modules/language/language.admin.inc b/core/modules/language/language.admin.inc index b5d3560..c4b5d8d 100644 --- a/core/modules/language/language.admin.inc +++ b/core/modules/language/language.admin.inc @@ -561,18 +561,18 @@ function theme_language_negotiation_configure_form($variables) { function language_negotiation_configure_form_submit($form, &$form_state) { $configurable_types = $form['#language_types']; - $configurable = config('system.language.types')->get('configurable'); - $config_values = array(); + $customized_types = config('system.language.types')->get('configurable'); + $customized = array(); $method_weights_type = array(); foreach ($configurable_types as $type) { - $config_values[$type] = in_array($type, $configurable); + $customized[$type] = in_array($type, $customized_types); $method_weights = array(); $enabled_methods = $form_state['values'][$type]['enabled']; $enabled_methods[LANGUAGE_NEGOTIATION_SELECTED] = TRUE; $method_weights_input = $form_state['values'][$type]['weight']; if (isset($form_state['values'][$type]['configurable'])) { - $config_values[$type] = !empty($form_state['values'][$type]['configurable']); + $customized[$type] = !empty($form_state['values'][$type]['configurable']); } foreach ($method_weights_input as $method_id => $weight) { @@ -587,7 +587,7 @@ function language_negotiation_configure_form_submit($form, &$form_state) { // Update non-configurable language types and the related language negotiation // configuration. - language_types_set(array_keys(array_filter($config_values))); + language_types_set(array_keys(array_filter($customized))); // Update the language negotiations after setting the configurability. foreach ($method_weights_type as $type => $method_weights) { @@ -599,7 +599,7 @@ function language_negotiation_configure_form_submit($form, &$form_state) { if (module_exists('block')) { // If there is an active language switcher for a language type that has been // made not configurable, deactivate it first. - $non_configurable = array_keys(array_diff($config_values, array_filter($config_values))); + $non_configurable = array_keys(array_diff($customized, array_filter($customized))); _language_disable_language_switcher($non_configurable); Drupal::service('plugin.manager.block')->clearCachedDefinitions(); } @@ -627,10 +627,8 @@ function language_negotiation_configure_browser_form($form, &$form_state) { // the list of existing and then predefined languages. if (empty($existing_languages)) { $language_options = language_admin_predefined_list(); - $default = key($language_options); } else { - $default = key($existing_languages); $language_options = array( t('Existing languages') => $existing_languages, t('Languages not yet added') => language_admin_predefined_list() diff --git a/core/modules/language/language.install b/core/modules/language/language.install index 9f74b97..b7b3c77 100644 --- a/core/modules/language/language.install +++ b/core/modules/language/language.install @@ -18,6 +18,7 @@ function language_install() { // Enable URL language detection for each configurable language type. require_once DRUPAL_ROOT . '/core/includes/language.inc'; foreach (language_types_get_configurable() as $type) { + module_load_include('inc', 'language', 'language.negotiation'); language_negotiation_set($type, array(LANGUAGE_NEGOTIATION_URL => 0)); } }