diff --git a/core/modules/language/config/tour.tour.language-add.yml b/core/modules/language/config/tour.tour.language-add.yml new file mode 100644 index 0000000..33afce0 --- /dev/null +++ b/core/modules/language/config/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.

You will get an additional form when adding a custom language where you can provide the language''s name, code, and directionality.

' + 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/tour.tour.language-edit.yml b/core/modules/language/config/tour.tour.language-edit.yml new file mode 100644 index 0000000..988114c --- /dev/null +++ b/core/modules/language/config/tour.tour.language-edit.yml @@ -0,0 +1,43 @@ +id: language-edit +module: language +label: Editing languages +langcode: en +routes: + - route_name: language.edit +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 language''s code 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-name: + id: language-edit-name + plugin: text + label: 'Language name' + body: '

The language name is used throughout the site for all users and is typically written in the same language it represents.

' + weight: 3 + attributes: + data-id: edit-name + 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 + 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/tour.tour.language.yml b/core/modules/language/config/tour.tour.language.yml new file mode 100644 index 0000000..4c4912d --- /dev/null +++ b/core/modules/language/config/tour.tour.language.yml @@ -0,0 +1,43 @@ +id: language +module: language +label: Language +langcode: en +routes: + - route_name: language.admin_overview +tips: + language-overview: + id: language-overview + plugin: text + label: Languages + body: '

The "Languages" page provides features for adding, editing, deleting, and reordering 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.

After adding a new language, it will be displayed in the language list and can then be edited, reordered, and deleted.

' + weight: 2 + attributes: + data-class: action-links + 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.

This order will determine the order in which languages are displayed in lists on the site such as in the language switcher blocks provided by the "Interface translation" and "Content translation" modules.

If you reorder the languages, click the "Save configuration" button when you are done for the changes to take effect.

' + weight: 3 + attributes: + data-class: draggable + language-operations: + id: language-operations + plugin: text + label: 'Modifying languages' + body: '

Operations are provided for editing and deleting your languages.

You can edit the language''s name, code, and directionality.

Deleted languages can be added back at a later time. Note that you cannot delete the site''s default language.

' + weight: 4 + attributes: + data-class: dropbutton-action + 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: 5 diff --git a/core/modules/language/language.module b/core/modules/language/language.module index c616837..27e2295 100644 --- a/core/modules/language/language.module +++ b/core/modules/language/language.module @@ -13,6 +13,7 @@ use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl; use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrlFallback; use Drupal\node\NodeTypeInterface; +use Drupal\Core\Entity\EntityInterface; /** * Implements hook_help(). @@ -736,3 +737,41 @@ function language_system_regional_settings_form_submit($form, &$form_state) { $language->default = TRUE; language_save($language); } + +/** + * 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 enabled 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 enabled language.'); + } + $tour_tip->set('body', $tour_tip->get('body') . '

' . $additional_overview . '

'); + } + else if ($tour_tip->get('id') == 'language-continue') { + $additional_continue = ''; + $additional_modules = array(); + if (! Drupal::service('module_handler')->moduleExists('locale')) { + $additional_modules[] = 'Interface translation'; + } + if (! Drupal::service('module_handler')->moduleExists('translation_entity')) { + $additional_modules[] = '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/lib/Drupal/language/Tests/LanguageTourTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageTourTest.php new file mode 100644 index 0000000..5625103 --- /dev/null +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageTourTest.php @@ -0,0 +1,62 @@ + 'Language tour tests', + 'description' => 'Tests the Language tours.', + 'group' => 'Tour', + ); + } + + protected function setUp() { + parent::setUp(); + $this->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(); + } + + public function testLanguageAddTour() { + $this->drupalGet('admin/config/regional/language/add'); + $this->assertTourTips(); + } + + public function testLanguageEditTour() { + $this->drupalGet('admin/config/regional/language/edit/en'); + $this->assertTourTips(); + } +}