diff options
Diffstat (limited to 'core/modules/language/language.module')
-rw-r--r-- | core/modules/language/language.module | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/core/modules/language/language.module b/core/modules/language/language.module index 516f54fb7b1..8066aa9194c 100644 --- a/core/modules/language/language.module +++ b/core/modules/language/language.module @@ -29,42 +29,42 @@ function language_help($route_name, RouteMatchInterface $route_match) { case 'help.page.language': $output = ''; $output .= '<h3>' . t('About') . '</h3>'; - $output .= '<p>' . t('The Language module allows you to configure the languages used on your site, and provides information for the <a href=":content">Content Translation</a>, <a href=":interface">Interface Translation</a>, and <a href=":configuration">Configuration Translation</a> modules, if they are enabled. For more information, see the <a href=":doc_url">online documentation for the Language module</a>.', array(':doc_url' => 'https://www.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')) : '#')) . '</p>'; + $output .= '<p>' . t('The Language module allows you to configure the languages used on your site, and provides information for the <a href=":content">Content Translation</a>, <a href=":interface">Interface Translation</a>, and <a href=":configuration">Configuration Translation</a> modules, if they are enabled. For more information, see the <a href=":doc_url">online documentation for the Language module</a>.', [':doc_url' => 'https://www.drupal.org/documentation/modules/language', ':content' => (\Drupal::moduleHandler()->moduleExists('content_translation')) ? \Drupal::url('help.page', ['name' => 'content_translation']) : '#', ':interface' => (\Drupal::moduleHandler()->moduleExists('locale')) ? \Drupal::url('help.page', ['name' => 'locale']) : '#', ':configuration' => (\Drupal::moduleHandler()->moduleExists('config_translation')) ? \Drupal::url('help.page', ['name' => 'config_translation']) : '#']) . '</p>'; $output .= '<h3>' . t('Uses') . '</h3>'; $output .= '<dl>'; $output .= '<dt>' . t('Adding languages') . '</dt>'; - $output .= '<dd>' . t('You can add languages on the <a href=":language_list">Languages</a> page by selecting <em>Add language</em> and choosing a language from the drop-down menu. This language is then displayed in the languages list, where it can be configured further. If the <a href=":interface">Interface translation module</a> is enabled, and the <em>translation server</em> is set as a translation source, then the interface translation for this language is automatically downloaded as well.', array(':language_list' => \Drupal::url('entity.configurable_language.collection'), ':interface' => (\Drupal::moduleHandler()->moduleExists('locale')) ? \Drupal::url('help.page', array('name' => 'locale')) : '#')) . '</dd>'; + $output .= '<dd>' . t('You can add languages on the <a href=":language_list">Languages</a> page by selecting <em>Add language</em> and choosing a language from the drop-down menu. This language is then displayed in the languages list, where it can be configured further. If the <a href=":interface">Interface translation module</a> is enabled, and the <em>translation server</em> is set as a translation source, then the interface translation for this language is automatically downloaded as well.', [':language_list' => \Drupal::url('entity.configurable_language.collection'), ':interface' => (\Drupal::moduleHandler()->moduleExists('locale')) ? \Drupal::url('help.page', ['name' => 'locale']) : '#']) . '</dd>'; $output .= '<dt>' . t('Adding custom languages') . '</dt>'; $output .= '<dd>' . t('You can add a language that is not provided in the drop-down list by choosing <em>Custom language</em> at the end of the list. You then have to configure its language code, name, and direction in the form provided.') . '</dd>'; $output .= '<dt>' . t('Configuring content languages') . '</dt>'; - $output .= '<dd>' . t('By default, content is created in the site\'s default language and no language selector is displayed on content creation pages. On the <a href=":content_language">Content language</a> page you can customize the language configuration for any supported content entity on your site (for example for content types or menu links). After choosing an entity, you are provided with a drop-down menu to set the default language and a check-box to display language selectors.', array(':content_language' => \Drupal::url('language.content_settings_page'))) . '</dd>'; + $output .= '<dd>' . t('By default, content is created in the site\'s default language and no language selector is displayed on content creation pages. On the <a href=":content_language">Content language</a> page you can customize the language configuration for any supported content entity on your site (for example for content types or menu links). After choosing an entity, you are provided with a drop-down menu to set the default language and a check-box to display language selectors.', [':content_language' => \Drupal::url('language.content_settings_page')]) . '</dd>'; $output .= '<dt>' . t('Adding a language switcher block') . '</dt>'; - $output .= '<dd>' . t('If the Block module is enabled, then you can add a language switcher block on the <a href=":blocks">Block layout</a> page to allow users to switch between languages.', array(':blocks' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#')) . '</dd>'; + $output .= '<dd>' . t('If the Block module is enabled, then you can add a language switcher block on the <a href=":blocks">Block layout</a> page to allow users to switch between languages.', [':blocks' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#']) . '</dd>'; $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.', array(':blocks' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#')) . '</dd>'; + $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 .= '<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.', array(':detection' => \Drupal::url('language.negotiation'))); + $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>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.', array(':language_list' => \Drupal::url('entity.configurable_language.collection'))) . '</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 .= '</dl>'; return $output; case 'entity.configurable_language.collection': - $output = '<p>' . t('Reorder the configured languages to set their order in the language switcher block and, when editing content, in the list of selectable languages. This ordering does not impact <a href=":detection">detection and selection</a>.', array(':detection' => \Drupal::url('language.negotiation'))) . '</p>'; - $output .= '<p>' . t('The site default language can also be set. It is not recommended to change the default language on a working site. <a href=":language-detection">Configure the Selected language</a> setting on the detection and selection page to change the fallback language for language selection.', array(':language-detection' => \Drupal::url('language.negotiation'))) . '</p>'; + $output = '<p>' . t('Reorder the configured languages to set their order in the language switcher block and, when editing content, in the list of selectable languages. This ordering does not impact <a href=":detection">detection and selection</a>.', [':detection' => \Drupal::url('language.negotiation')]) . '</p>'; + $output .= '<p>' . t('The site default language can also be set. It is not recommended to change the default language on a working site. <a href=":language-detection">Configure the Selected language</a> setting on the detection and selection page to change the fallback language for language selection.', [':language-detection' => \Drupal::url('language.negotiation')]) . '</p>'; return $output; case 'language.add': return '<p>' . t('Add a language to be supported by your site. If your desired language is not available, pick <em>Custom language...</em> at the end and provide a language code and other details manually.') . '</p>'; case 'language.negotiation': - $output = '<p>' . t('Define how to decide which language is used to display page elements (primarily text provided by 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 detection 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. The default language can be changed in the <a href=":admin-change-language">list of languages</a>.', array(':admin-change-language' => \Drupal::url('entity.configurable_language.collection'))) . '</p>'; + $output = '<p>' . t('Define how to decide which language is used to display page elements (primarily text provided by 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 detection 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. The default language can be changed in the <a href=":admin-change-language">list of languages</a>.', [':admin-change-language' => \Drupal::url('entity.configurable_language.collection')]) . '</p>'; return $output; case 'language.negotiation_session': @@ -72,11 +72,11 @@ function language_help($route_name, RouteMatchInterface $route_match) { return $output; case 'language.negotiation_browser': - $output = '<p>' . t('Browsers use different language codes to refer to the same languages. Internally, a best effort is made to determine the correct language based on the code that the browser sends. You can add and edit additional mappings from browser language codes to <a href=":configure-languages">site languages</a>.', array(':configure-languages' => \Drupal::url('entity.configurable_language.collection'))) . '</p>'; + $output = '<p>' . t('Browsers use different language codes to refer to the same languages. Internally, a best effort is made to determine the correct language based on the code that the browser sends. You can add and edit additional mappings from browser language codes to <a href=":configure-languages">site languages</a>.', [':configure-languages' => \Drupal::url('entity.configurable_language.collection')]) . '</p>'; return $output; case 'language.negotiation_selected': - $output = '<p>' . 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 (e.g., when using an empty path prefix or using the default domain). <a href=":admin-change-language">Changing the site\'s default language</a> itself might have other undesired side effects.', array(':admin-change-language' => \Drupal::url('entity.configurable_language.collection'))) . '</p>'; + $output = '<p>' . 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 (e.g., when using an empty path prefix or using the default domain). <a href=":admin-change-language">Changing the site\'s default language</a> itself might have other undesired side effects.', [':admin-change-language' => \Drupal::url('entity.configurable_language.collection')]) . '</p>'; return $output; case 'entity.block.edit_form': @@ -100,16 +100,16 @@ function language_help($route_name, RouteMatchInterface $route_match) { * Implements hook_theme(). */ function language_theme() { - return array( - 'language_negotiation_configure_form' => array( + return [ + 'language_negotiation_configure_form' => [ 'render element' => 'form', 'file' => 'language.admin.inc', - ), - 'language_content_settings_table' => array( + ], + 'language_content_settings_table' => [ 'render element' => 'element', 'file' => 'language.admin.inc', - ), - ); + ], + ]; } /** @@ -123,18 +123,18 @@ function language_element_info_alter(&$type) { // field. if (isset($type['language_select'])) { if (!isset($type['language_select']['#process'])) { - $type['language_select']['#process'] = array(); + $type['language_select']['#process'] = []; } if (!isset($type['language_select']['#theme_wrappers'])) { - $type['language_select']['#theme_wrappers'] = array(); + $type['language_select']['#theme_wrappers'] = []; } - $type['language_select']['#process'] = array_merge($type['language_select']['#process'], array( + $type['language_select']['#process'] = array_merge($type['language_select']['#process'], [ 'language_process_language_select', - array('Drupal\Core\Render\Element\Select', 'processSelect'), - array('Drupal\Core\Render\Element\RenderElement', 'processAjaxForm'), - )); + ['Drupal\Core\Render\Element\Select', 'processSelect'], + ['Drupal\Core\Render\Element\RenderElement', 'processAjaxForm'], + ]); $type['language_select']['#theme'] = 'select'; - $type['language_select']['#theme_wrappers'] = array_merge($type['language_select']['#theme_wrappers'], array('form_element')); + $type['language_select']['#theme_wrappers'] = array_merge($type['language_select']['#theme_wrappers'], ['form_element']); $type['language_select']['#languages'] = LanguageInterface::STATE_CONFIGURABLE; $type['language_select']['#multiple'] = FALSE; } @@ -153,9 +153,9 @@ function language_process_language_select($element) { // Don't set the options if another module (translation for example) already // set the options. if (!isset($element['#options'])) { - $element['#options'] = array(); + $element['#options'] = []; foreach (\Drupal::languageManager()->getLanguages($element['#languages']) as $langcode => $language) { - $element['#options'][$langcode] = $language->isLocked() ? t('- @name -', array('@name' => $language->getName())) : $language->getName(); + $element['#options'][$langcode] = $language->isLocked() ? t('- @name -', ['@name' => $language->getName()]) : $language->getName(); } } return $element; @@ -168,7 +168,7 @@ function language_entity_base_field_info_alter(&$fields) { foreach ($fields as $definition) { // Set configurable form display for language fields with display options. if ($definition->getType() == 'language') { - foreach (array('form', 'view') as $type) { + foreach (['form', 'view'] as $type) { if ($definition->getDisplayOptions($type)) { // The related configurations will be purged manually on Language // module uninstallation. @see language_modules_uninstalled(). @@ -201,8 +201,8 @@ function language_configuration_element_submit(&$form, FormStateInterface $form_ } } $config = ContentLanguageSettings::loadByEntityTypeBundle($entity_type_id, $bundle); - $config->setDefaultLangcode($form_state->getValue(array($element_name, 'langcode'))); - $config->setLanguageAlterable($form_state->getValue(array($element_name, 'language_alterable'))); + $config->setDefaultLangcode($form_state->getValue([$element_name, 'langcode'])); + $config->setLanguageAlterable($form_state->getValue([$element_name, 'language_alterable'])); $config->save(); // Set the form_state languaged with the updated bundle. @@ -325,7 +325,7 @@ function language_modules_installed($modules) { // display definitions to make language fields display configurable. Since // this is not a hard dependency, and thus is not detected by the config // system, we have to clean up the related values manually. - foreach (array('entity_view_display', 'entity_form_display') as $key) { + foreach (['entity_view_display', 'entity_form_display'] as $key) { $displays = \Drupal::entityManager()->getStorage($key)->loadMultiple(); /** @var \Drupal\Core\Entity\Display\EntityDisplayInterface $display */ foreach ($displays as $display) { @@ -393,7 +393,7 @@ function language_preprocess_block(&$variables) { function language_get_browser_drupal_langcode_mappings() { $config = \Drupal::config('language.mappings'); if ($config->isNew()) { - return array(); + return []; } return $config->get('map'); } @@ -462,7 +462,7 @@ function language_tour_tips_alter(array &$tour_tips, EntityInterface $entity) { } elseif ($tour_tip->get('id') == 'language-continue') { $additional_continue = ''; - $additional_modules = array(); + $additional_modules = []; if (!Drupal::service('module_handler')->moduleExists('locale')) { $additional_modules[] = Drupal::service('module_handler')->getName('locale'); } |