Commit 35f15606 authored by alexpott's avatar alexpott

Issue #2017471 by rodrigoaguilera, balagan, clemens.tolboom, Kristen Pol,...

Issue #2017471 by rodrigoaguilera, balagan, clemens.tolboom, Kristen Pol, Outi, rpayanm, danylevskyi, mon_franco, Antti J. Salminen, aloyr, thlafon, Marc Hannaford, kreatIL, oussema, David Hernández: Multilingual tour for language section
parent a0e9ed19
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: '<p>This page provides the ability to add common languages to your site.</p><p>If the desired language is not available, you can add a custom language.</p>'
weight: 1
language-add-choose:
id: language-add-choose
plugin: text
label: 'Select language'
body: '<p>Choose a language from the list, or choose "Custom language..." at the end of the list.</p><p>Click the "Add language" button when you are done choosing your language.</p><p>When adding a custom language, you will get an additional form where you can provide the name, code, and direction of the language.</p>'
weight: 2
attributes:
data-id: edit-predefined-langcode
language-add-continue:
id: language-add-continue
plugin: text
label: 'Continuing on'
body: '<p>Now that you have an overview of the "Add languages" feature, you can continue by:<ul><li>Adding a language</li><li>Adding a custom language</li><li><a href="[site:url]/admin/config/regional/language">Viewing configured languages</a></li></ul></p>'
weight: 3
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: '<p>This page provides the ability to edit a language on your site, including custom languages.</p>'
weight: 1
language-edit-langcode:
id: language-edit-langcode
plugin: text
label: 'Language code'
body: '<p>You cannot change the code of a language on the site, since it is used by the system to keep track of the language.</p>'
weight: 2
attributes:
data-id: edit-langcode-view
language-edit-label:
id: language-edit-label
plugin: text
label: 'Language name'
body: '<p>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.</p>'
weight: 3
attributes:
data-id: edit-label
language-edit-direction:
id: language-edit-direction
plugin: text
label: 'Language direction'
body: '<p>Choose if the language is a "Left to right" or "Right to left" language.</p><p>Note that not all themes support "Right to left" layouts, so test your theme if you are using "Right to left".</p>'
weight: 4
attributes:
data-id: edit-direction--wrapper--description
language-edit-continue:
id: language-edit-continue
plugin: text
label: 'Continuing on'
body: '<p>Now that you have an overview of the "Edit language" feature, you can continue by:<ul><li>Editing a language</li><li><a href="[site:url]/admin/config/regional/language">Viewing configured languages</a></li></ul></p>'
weight: 5
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: '<p>The "Languages" page allows you to add, edit, delete, and reorder languages for the site.</p>'
weight: 1
language-add:
id: language-add
plugin: text
label: 'Adding languages'
body: '<p>To add more languages to your site, click the "Add language" button.</p><p>Added languages will be displayed in the language list and can then be edited or deleted.</p>'
weight: 2
attributes:
data-class: button-action
language-reorder:
id: language-reorder
plugin: text
label: 'Reordering languages'
body: '<p>To reorder the languages on your site, use the drag icons next to each language.</p><p>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.</p><p>When you are done with reordering the languages, click the "Save configuration" button for the changes to take effect.</p>'
weight: 3
attributes:
data-class: draggable
language-default:
id: language-default
plugin: text
label: 'Set a language as default'
body: '<p>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 where no choice is made but a language should be set, for example as the language of the displayed interface.</p>'
weight: 4
attributes:
data-class: form-item-site-default-language
language-operations:
id: language-operations
plugin: text
label: 'Modifying languages'
body: '<p>Operations are provided for editing and deleting your languages.</p><p>You can edit the name and the direction of the language.</p><p>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.</p>'
weight: 5
attributes:
data-class: dropbutton-wrapper
language-continue:
id: language-continue
plugin: text
label: 'Continuing on'
body: '<p>Now that you have an overview of the "Languages" page, you can continue by:<ul><li><a href="[site:url]/admin/config/regional/language/add">Adding a language</a></li><li>Reordering languages</li><li>Editing a language</li><li>Deleting a language</li></ul></p>'
weight: 6
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
use Drupal\Core\Access\AccessResult; use Drupal\Core\Access\AccessResult;
use Drupal\Core\Entity\ContentEntityFormInterface; use Drupal\Core\Entity\ContentEntityFormInterface;
use Drupal\Core\Entity\EntityFormInterface; use Drupal\Core\Entity\EntityFormInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
...@@ -55,7 +56,7 @@ function language_help($route_name, RouteMatchInterface $route_match) { ...@@ -55,7 +56,7 @@ function language_help($route_name, RouteMatchInterface $route_match) {
return $output; return $output;
case 'entity.configurable_language.collection': case 'entity.configurable_language.collection':
$output = '<p>' . 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 <a href="@detection">detection and selection</a>.', array('@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>.', 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('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>';
return $output; return $output;
...@@ -80,13 +81,13 @@ function language_help($route_name, RouteMatchInterface $route_match) { ...@@ -80,13 +81,13 @@ function language_help($route_name, RouteMatchInterface $route_match) {
case 'entity.block.edit_form': case 'entity.block.edit_form':
if (($block = $route_match->getParameter('block')) && $block->getPluginId() == 'language_block:language_interface') { if (($block = $route_match->getParameter('block')) && $block->getPluginId() == 'language_block:language_interface') {
return '<p>' . t('With multiple languages added, registered users can select their preferred language and authors can assign a specific language to content.') . '</p>'; return '<p>' . t('With multiple languages configured, registered users can select their preferred language and authors can assign a specific language to content.') . '</p>';
} }
break; break;
case 'block.admin_add': case 'block.admin_add':
if ($route_match->getParameter('plugin_id') == 'language_block:language_interface') { if ($route_match->getParameter('plugin_id') == 'language_block:language_interface') {
return '<p>' . t('With multiple languages added, registered users can select their preferred language and authors can assign a specific language to content.') . '</p>'; return '<p>' . t('With multiple languages configured, registered users can select their preferred language and authors can assign a specific language to content.') . '</p>';
} }
break; break;
...@@ -511,3 +512,41 @@ function language_entity_field_access($operation, FieldDefinitionInterface $fiel ...@@ -511,3 +512,41 @@ function language_entity_field_access($operation, FieldDefinitionInterface $fiel
} }
return AccessResult::neutral(); 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') . '<p>' . $additional_overview . '</p>');
}
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:') . '<ul>';
foreach ($additional_modules as $additional_module) {
$additional_continue .= '<li>' . $additional_module . '</li>';
}
$additional_continue .= '</ul>';
}
if (!empty($additional_continue)) {
$tour_tip->set('body', $tour_tip->get('body') . '<p>' . $additional_continue . '</p>');
}
}
}
}
<?php
/**
* @file
* Contains \Drupal\language\Tests\LanguageTourTest.
*/
namespace Drupal\language\Tests;
use Drupal\tour\Tests\TourTestBase;
/**
* Tests tour functionality.
*
* @group tour
*/
class LanguageTourTest extends TourTestBase {
/**
* An admin user with administrative permissions for views.
*
* @var \Drupal\user\UserInterface
*/
protected $adminUser;
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('language', 'tour');
/**
* {@inheritdoc}
*/
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();
}
/**
* 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();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment