Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / web / core / modules / language / language.module
index 8066aa9194c787cb84c3b038c7f13503fd74a772..e4c132040a39112ad21bffbdcfc559763f637a7f 100644 (file)
@@ -15,7 +15,6 @@ use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Language\LanguageInterface;
 use Drupal\Core\Routing\RouteMatchInterface;
 use Drupal\Core\Session\AccountInterface;
-use Drupal\language\ConfigurableLanguageInterface;
 use Drupal\language\Entity\ContentLanguageSettings;
 use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUI;
 use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl;
@@ -43,15 +42,15 @@ function language_help($route_name, RouteMatchInterface $route_match) {
       $output .= '<dt>' . t('Making a block visible per language') . '</dt>';
       $output .= '<dd>' . t('If the Block module is enabled, then the Language module allows you to set the visibility of a block based on selected languages on the <a href=":blocks">Block layout</a> page.', [':blocks' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#']) . '</dd>';
       $output .= '<dt>' . t('Choosing user languages') . '</dt>';
-      $output .= '<dd>' . t('Users can choose a <em>Site language</em> on their profile page. This language is used for email messages, and can be used by modules to determine a user\'s language. It can also be used for interface text, if the <em>User</em> method is enabled as a <em>Detection and selection</em> method (see below). Administrative users can choose a separate <em>Administration pages language</em> for the interface text on administration pages. This configuration is only available on the user\'s profile page if the <em>Account administration pages</em> method is enabled (see below).') . '</dd>';
+      $output .= '<dd>' . t("Users can choose a <em>Site language</em> on their profile page. This language is used for email messages, and can be used by modules to determine a user's language. It can also be used for interface text, if the <em>User</em> method is enabled as a <em>Detection and selection</em> method (see below). Administrative users can choose a separate <em>Administration pages language</em> for the interface text on administration pages. This configuration is only available on the user's profile page if the <em>Account administration pages</em> method is enabled (see below).") . '</dd>';
       $output .= '<dt>' . t('Language detection and selection') . '</dt>';
       $output .= '<dd>' . t('The <a href=":detection">Detection and selection</a> page provides several methods for deciding which language is used for displaying interface text. When a method detects and selects an interface language, then the following methods in the list are not applied. You can order them by importance, with your preferred method at the top of the list, followed by one or several fall-back methods.', [':detection' => \Drupal::url('language.negotiation')]);
       $output .= '<ul><li>' . t('<em>URL</em> sets the interface language based on a path prefix or domain (for example specifying <em>de</em> for German would result in URLs like <em>example.com/de/contact</em>). The default language does not require a path prefix, but can have one assigned as well. If the language detection is done by domain name, a domain needs to be specified for each language.') . '</li>';
       $output .= '<li>' . t('<em>Session</em> determines the interface language from a request or session parameter (for example <em>example.com?language=de</em> would set the interface language to German based on the use of <em>de</em> as the <em>language</em> parameter).') . '</li>';
-      $output .= '<li>' . t('<em>User</em> follows the language configuration set on the user\'s profile page.') . '</li>';
+      $output .= '<li>' . t("<em>User</em> follows the language configuration set on the user's profile page.") . '</li>';
       $output .= '<li>' . t('<em>Browser</em> sets the interface language based on the browser\'s language settings. Since browsers use different language codes to refer to the same languages, you can add and edit languages codes to map the browser language codes to the <a href=":language_list">language codes</a> used on your site.', [':language_list' => \Drupal::url('entity.configurable_language.collection')]) . '</li>';
       $output .= '<li>' . t('<em>Account administration pages</em> follows the configuration set as <em>Administration pages language</em> on the profile page of an administrative user. This method is similar to the <em>User</em> method, but only sets the interface text language on administration pages, independent of the interface text language on other pages.') . '</li>';
-      $output .= '<li>' . t('<em>Selected language</em> allows you to specify the site\'s default language or a specific language as the fall-back language. This method should be listed last.') . '</li></ul></dd>';
+      $output .= '<li>' . t("<em>Selected language</em> allows you to specify the site's default language or a specific language as the fall-back language. This method should be listed last.") . '</li></ul></dd>';
       $output .= '</dl>';
       return $output;
 
@@ -193,7 +192,7 @@ function language_configuration_element_submit(&$form, FormStateInterface $form_
       $bundle = $values['bundle'];
       $form_object = $form_state->getFormObject();
       if ($form_object instanceof EntityFormInterface) {
-        /** @var EntityFormInterface $form_object */
+        /** @var \Drupal\Core\Entity\EntityFormInterface $form_object */
         $entity = $form_object->getEntity();
         if ($entity->getEntityType()->getBundleOf()) {
           $bundle = $entity->id();
@@ -205,7 +204,7 @@ function language_configuration_element_submit(&$form, FormStateInterface $form_
       $config->setLanguageAlterable($form_state->getValue([$element_name, 'language_alterable']));
       $config->save();
 
-      // Set the form_state languaged with the updated bundle.
+      // Set the form_state language with the updated bundle.
       $form_state->set('language', $language);
     }
   }
@@ -272,6 +271,8 @@ function language_get_default_langcode($entity_type, $bundle) {
  *
  * @deprecated in Drupal 8.0.x-dev, will be removed before Drupal 9.0.0.
  *   Use \Drupal::config('language.negotiation')->get('url.prefixes') instead.
+ *
+ * @see https://www.drupal.org/node/2912748
  */
 function language_negotiation_url_prefixes() {
   return \Drupal::config('language.negotiation')->get('url.prefixes');
@@ -301,6 +302,8 @@ function language_negotiation_url_prefixes_update() {
  *
  * @deprecated in Drupal 8.0.x-dev, will be removed before Drupal 9.0.0.
  *   Use \Drupal::config('language.negotiation')->get('url.domains') instead.
+ *
+ * @see https://www.drupal.org/node/2912748
  */
 function language_negotiation_url_domains() {
   return \Drupal::config('language.negotiation')->get('url.domains');
@@ -342,38 +345,6 @@ function language_modules_uninstalled($modules) {
   language_modules_installed($modules);
 }
 
-/**
- * Implements hook_ENTITY_TYPE_insert() for 'configurable_language'.
- */
-function language_configurable_language_insert(ConfigurableLanguageInterface $language) {
-  if ($language->isLocked()) {
-    return;
-  }
-
-  // Add language to the list of language domains.
-  $config = \Drupal::configFactory()->getEditable('language.negotiation');
-  $domains = $config->get('url.domains');
-  $domains[$language->id()] = '';
-  $config->set('url.domains', $domains)->save();
-}
-
-/**
- * Implements hook_ENTITY_TYPE_delete() for 'configurable_language'.
- */
-function language_configurable_language_delete(ConfigurableLanguageInterface $language) {
-  // Remove language from language prefix list.
-  $config = \Drupal::configFactory()->getEditable('language.negotiation');
-  $prefixes = $config->get('url.prefixes');
-  unset($prefixes[$language->id()]);
-  $config->set('url.prefixes', $prefixes)->save();
-
-  // Remove language from language domain list.
-  $config = \Drupal::configFactory()->getEditable('language.negotiation');
-  $domains = $config->get('url.domains');
-  unset($domains[$language->id()]);
-  $config->set('url.domains', $domains)->save();
-}
-
 /**
  * Implements hook_preprocess_HOOK() for block templates.
  */