diff --git a/core/modules/language/language.module b/core/modules/language/language.module index e1298f7..ef07515 100644 --- a/core/modules/language/language.module +++ b/core/modules/language/language.module @@ -1,11 +1,11 @@ -' . t('About') . ''; $output .= '

' . t('The Language module allows you to configure the languages used on your site, and provides information for the for Content Translation, Interface Translation, and Configuration Translation modules, if they are enabled. For more information, see the online documentation for the Language module.', array('!doc_url' => 'https://drupal.org/documentation/modules/language', '!content' => (\Drupal::moduleHandler()->moduleExists('content_translation')) ? \Drupal::url('help.page', array('name' => 'content_translation')) : '#', '!interface' => (\Drupal::moduleHandler()->moduleExists('locale')) ? \Drupal::url('help.page', array('name' => 'locale')) : '#', '!configuration' => (\Drupal::moduleHandler()->moduleExists('config_translation')) ? \Drupal::url('help.page', array('name' => 'config_translation')) : '#')) . '

'; @@ -49,37 +50,42 @@ function language_help($path, $arg) { $output .= ''; return $output; - case 'admin/config/regional/language': + + case 'language.admin_overview': return '

' . t('With multiple languages enabled, registered users may select their preferred language and authors can assign a specific language to content. The selection of what language is used to display page elements is made depending on the detection menthod settings in the Detection and Selection tab.', array('!detection' => \Drupal::url('language.negotiation'))) . '

'; - case 'admin/config/regional/language/add': + case 'language.add': return '

' . t('Add a language to be supported by your site. If your desired language is not available, pick Custom language... at the end and provide a language code and other details manually.') . '

'; - case 'admin/config/regional/language/detection': + case 'language.negotiation': $output = '

' . t('Define how to decide which language is used to display page elements (primarily text provided by Drupal and modules, such as field labels and help text). This decision is made by evaluating a series of detection methods for languages; the first detection method that gets a result will determine which language is used for that type of text. Be aware that some language negotiation methods are unreliable under certain conditions, such as browser detection when page-caching is enabled and a user is not currently logged in. Define the order of evaluation of language detection methods on this page. Default language can be changed at the Regional settings page.', array('!region-settings' => \Drupal::url('system.regional_settings'))) . '

'; return $output; - case 'admin/config/regional/language/detection/session': + case 'language.negotiation_session': $output = '

' . t('Determine the language from a request/session parameter. Example: "http://example.com?language=de" sets language to German based on the use of "de" within the "language" parameter.') . '

'; return $output; - case 'admin/config/regional/language/detection/browser': + case 'language.negotiation_browser': $output = '

' . t('Browsers use different language codes to refer to the same languages. You can add and edit mappings from browser language codes to the languages used by Drupal.', array('!configure-languages' => \Drupal::url('language.admin_overview'))) . '

'; return $output; - case 'admin/config/regional/language/detection/selected': + case 'language.negotiation_selected': $output = '

' . t('Changing the selected language here (and leaving this option as the last among the detection and selection options) is the easiest way to change the fallback language for the website, if you need to change how your site works by default (eg. when using an empty path prefix or using the default domain). Changing the site\'s default language itself might have other undesired side effects.', array('!admin-change-language' => \Drupal::url('language.admin_overview'))) . '

'; - return $output; - case 'admin/structure/block/manage/%': - case 'admin/structure/block/add/%/%': - if ($arg[4] == 'language' && $arg[5] == 'language_interface') { - return '

' . t('With multiple languages enabled, registered users can select their preferred language and authors can assign a specific language to content.') . '

'; + case 'block.admin_edit': + if (($block = $request->attributes->get('block')) && $block->get('plugin') == 'language_block:language_interface') { + return '

' . t('With multiple languages added, registered users can select their preferred language and authors can assign a specific language to content.') . '

'; } break; - case 'admin/config/regional/content-language': + case 'block.admin_add': + if ($request->attributes->get('plugin_id') == 'language_block:language_interface') { + return '

' . t('With multiple languages added, registered users can select their preferred language and authors can assign a specific language to content.') . '

'; + } + break; + + case 'language.content_settings_page': return t('Change language settings for content types, taxonomy vocabularies, user profiles, or any other supported element on your site. By default, language settings hide the language selector and the language is the site\'s default language.'); } } @@ -363,7 +369,7 @@ function language_get_default_configuration_settings_key($entity_type, $bundle) // Replace all the characters that are not letters, numbers or "_" with "_". $entity_type = preg_replace('/[^0-9a-zA-Z_]/', "_", $entity_type); $bundle = preg_replace('/[^0-9a-zA-Z_]/', "_", $bundle); - return $entity_type . '.' . $bundle . '.language.default_configuration'; + return 'entities.' . $entity_type . '.' . $bundle . '.language.default_configuration'; } /** @@ -446,9 +452,7 @@ function language_save($language) { $language_entity->direction = isset($language->direction) ? $language->direction : '0'; $language_entity->locked = !empty($language->locked); $language_entity->weight = isset($language->weight) ? $language->weight : 0; - - // Save the record and inform others about the change. - $multilingual = \Drupal::languageManager()->isMultilingual(); + $language_entity->setDefault(!empty($language->default)); $language_entity->save(); $t_args = array('%language' => $language->name, '%langcode' => $language->id); if ($language->is_new) { @@ -458,30 +462,6 @@ function language_save($language) { watchdog('language', 'The %language (%langcode) language has been updated.', $t_args); } - if (!empty($language->default)) { - // Update the config. Saving the configuration fires and event that causes - // the container to be rebuilt. - \Drupal::config('system.site')->set('langcode', $language->id)->save(); - \Drupal::service('language.default')->set($language); - } - - $language_manager = \Drupal::languageManager(); - $language_manager->reset(); - if ($language_manager instanceof ConfigurableLanguageManagerInterface) { - $language_manager->updateLockedLanguageWeights(); - } - - // Update URL Prefixes for all languages after the new default language is - // propagated and the LanguageManagerInterface::getLanguages() cache is - // flushed. - language_negotiation_url_prefixes_update(); - - // If after adding this language the site will become multilingual, we need to - // rebuild language services. - if (!$multilingual && $language->is_new) { - ConfigurableLanguageManager::rebuildServices(); - } - return $language; }