diff --git a/core/modules/language/config/install/tour.tour.language-add.yml b/core/modules/language/config/install/tour.tour.language-add.yml new file mode 100644 index 0000000..8f39e49 --- /dev/null +++ b/core/modules/language/config/install/tour.tour.language-add.yml @@ -0,0 +1,27 @@ +id: language-add +module: language +label: 'Adding languages' +langcode: en +routes: + - route_name: language.add +tips: + language-add-overview: + id: language-add-overview + plugin: text + label: 'Adding languages' + body: '

This page provides the ability to add common languages to your site.

If the desired language is not available, you can add a custom language.

' + weight: 1 + language-add-choose: + id: language-add-choose + plugin: text + label: 'Select language' + body: '

Choose a language from the list, or choose "Custom language..." at the end of the list.

Click the "Add language" button when you are done choosing your language.

When adding a custom language, you will get an additional form where you can provide the name, code, and direction of the language.

' + weight: 2 + attributes: + data-id: edit-predefined-langcode + language-add-continue: + id: language-add-continue + plugin: text + label: 'Continuing on' + body: '

Now that you have an overview of the "Add languages" feature, you can continue by:

' + weight: 3 diff --git a/core/modules/language/config/install/tour.tour.language-edit.yml b/core/modules/language/config/install/tour.tour.language-edit.yml new file mode 100644 index 0000000..a166ce1 --- /dev/null +++ b/core/modules/language/config/install/tour.tour.language-edit.yml @@ -0,0 +1,43 @@ +id: language-edit +module: language +label: Editing languages +langcode: en +routes: + - route_name: entity.configurable_language.edit_form +tips: + language-edit-overview: + id: language-edit-overview + plugin: text + label: 'Editing languages' + body: '

This page provides the ability to edit a language on your site, including custom languages.

' + weight: 1 + language-edit-langcode: + id: language-edit-langcode + plugin: text + label: 'Language code' + body: '

You cannot change the code of a language on the site, since it is used by the system to keep track of the language.

' + weight: 2 + attributes: + data-id: edit-langcode-view + language-edit-label: + id: language-edit-label + plugin: text + label: 'Language name' + body: '

The language name is used throughout the site for all users and is written in English. Names of built-in languages can be translated using the Interface Translation module, and names of both built-in and custom languages can be translated using the Configuration Translation module.

' + weight: 3 + attributes: + data-id: edit-label + language-edit-direction: + id: language-edit-direction + plugin: text + label: 'Language direction' + body: '

Choose if the language is a "Left to right" or "Right to left" language.

Note that not all themes support "Right to left" layouts, so test your theme if you are using "Right to left".

' + weight: 4 + attributes: + data-id: edit-direction--wrapper--description + language-edit-continue: + id: language-edit-continue + plugin: text + label: 'Continuing on' + body: '

Now that you have an overview of the "Edit language" feature, you can continue by:

' + weight: 5 diff --git a/core/modules/language/config/install/tour.tour.language.yml b/core/modules/language/config/install/tour.tour.language.yml new file mode 100644 index 0000000..fb0c4d8 --- /dev/null +++ b/core/modules/language/config/install/tour.tour.language.yml @@ -0,0 +1,51 @@ +id: language +module: language +label: Language +langcode: en +routes: + - route_name: entity.configurable_language.collection +tips: + language-overview: + id: language-overview + plugin: text + label: Languages + body: '

The "Languages" page allows you to add, edit, delete, and reorder languages for the site.

' + weight: 1 + language-add: + id: language-add + plugin: text + label: 'Adding languages' + body: '

To add more languages to your site, click the "Add language" button.

Added languages will be displayed in the language list and can then be edited or deleted.

' + weight: 2 + attributes: + data-class: button-action + language-reorder: + id: language-reorder + plugin: text + label: 'Reordering languages' + body: '

To reorder the languages on your site, use the drag icons next to each language.

The order shown here is the display order for language lists on the site such as in the language switcher blocks provided by the Interface translation and Content translation modules.

When you are done with reordering the languages, click the "Save configuration" button for the changes to take effect.

' + weight: 3 + attributes: + data-class: draggable + language-default: + id: language-default + plugin: text + label: 'Set a language as default' + body: '

You can change the default language of the site by choosing one of your configured languages as default. The site will use the default language in situations were no choice is made but a language should be set, for example the language in which the interface of the site is displayed.

' + weight: 4 + attributes: + data-class: form-item-site-default-language + language-operations: + id: language-operations + plugin: text + label: 'Modifying languages' + body: '

Operations are provided for editing and deleting your languages.

You can edit the name and the direction of the language.

Deleted languages can be added back at a later time. Deleting a language will remove all interface translations associated with it, and content in this language will be set to be language neutral. Note that you cannot delete the default language of the site.

' + weight: 5 + attributes: + data-class: dropbutton-wrapper + language-continue: + id: language-continue + plugin: text + label: 'Continuing on' + body: '

Now that you have an overview of the "Languages" page, you can continue by:

' + weight: 6 diff --git a/core/modules/language/language.module b/core/modules/language/language.module index 5b2099e..fa7eb69 100644 --- a/core/modules/language/language.module +++ b/core/modules/language/language.module @@ -8,6 +8,7 @@ use Drupal\Core\Access\AccessResult; use Drupal\Core\Entity\ContentEntityFormInterface; use Drupal\Core\Entity\EntityFormInterface; +use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Form\FormStateInterface; @@ -55,7 +56,7 @@ function language_help($route_name, RouteMatchInterface $route_match) { return $output; case 'entity.configurable_language.collection': - $output = '

' . t('Reorder the added 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 detection and selection.', array('@detection' => \Drupal::url('language.negotiation'))) . '

'; + $output = '

' . 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 detection and selection.', array('@detection' => \Drupal::url('language.negotiation'))) . '

'; $output .= '

' . t('The site default language can also be set. It is not recommended to change the default language on a working site. Configure the Selected language setting on the detection and selection page to change the fallback language for language selection.', array('@language-detection' => \Drupal::url('language.negotiation'))) . '

'; return $output; @@ -80,13 +81,13 @@ function language_help($route_name, RouteMatchInterface $route_match) { case 'entity.block.edit_form': if (($block = $route_match->getParameter('block')) && $block->getPluginId() == '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.') . '

'; + return '

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

'; } break; case 'block.admin_add': if ($route_match->getParameter('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.') . '

'; + return '

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

'; } break; @@ -511,3 +512,41 @@ function language_entity_field_access($operation, FieldDefinitionInterface $fiel } return AccessResult::neutral(); } + +/** + * Implements hook_tour_tips_alter(). + */ +function language_tour_tips_alter(array &$tour_tips, EntityInterface $entity) { + foreach ($tour_tips as $tour_tip) { + if ($tour_tip->get('id') == 'language-overview') { + $additional_overview = ''; + if (Drupal::service('module_handler')->moduleExists('locale')) { + $additional_overview = t("This page also provides an overview of how much of the site's interface has been translated for each configured language."); + } + else { + $additional_overview = t("If the Interface Translation module is enabled, this page will provide an overview of how much of the site's interface has been translated for each configured language."); + } + $tour_tip->set('body', $tour_tip->get('body') . '

' . $additional_overview . '

'); + } + elseif ($tour_tip->get('id') == 'language-continue') { + $additional_continue = ''; + $additional_modules = array(); + if (!Drupal::service('module_handler')->moduleExists('locale')) { + $additional_modules[] = Drupal::service('module_handler')->getName('locale'); + } + if (!Drupal::service('module_handler')->moduleExists('content_translation')) { + $additional_modules[] = Drupal::service('module_handler')->getName('content_translation'); + } + if (!empty($additional_modules)) { + $additional_continue = t('Depending on your site features, additional modules that you might want to enable are:') . ''; + } + if (!empty($additional_continue)) { + $tour_tip->set('body', $tour_tip->get('body') . '

' . $additional_continue . '

'); + } + } + } +} diff --git a/core/modules/language/src/Tests/LanguageTourTest.php b/core/modules/language/src/Tests/LanguageTourTest.php new file mode 100644 index 0000000..98418b6 --- /dev/null +++ b/core/modules/language/src/Tests/LanguageTourTest.php @@ -0,0 +1,66 @@ +adminUser = $this->drupalCreateUser(array('administer languages', 'access tour')); + $this->drupalLogin($this->adminUser); + } + + /** + * Tests language tour tip availability. + */ + public function testLanguageTour() { + $this->drupalGet('admin/config/regional/language'); + $this->assertTourTips(); + } + + /** + * Go to add language page and check the tour tooltips. + */ + public function testLanguageAddTour() { + $this->drupalGet('admin/config/regional/language/add'); + $this->assertTourTips(); + } + + /** + * Go to edit language page and check the tour tooltips. + */ + public function testLanguageEditTour() { + $this->drupalGet('admin/config/regional/language/edit/en'); + $this->assertTourTips(); + } + +}