Loading core/modules/language/language.routing.yml +1 −1 Original line number Diff line number Diff line Loading @@ -81,7 +81,7 @@ language.negotiation_browser_delete: language.content_settings_page: path: '/admin/config/regional/content-language' defaults: _title: 'Content language' _title_callback: '\Drupal\language\Form\ContentLanguageSettingsForm::getTitle' _form: '\Drupal\language\Form\ContentLanguageSettingsForm' requirements: _permission: 'administer languages' core/modules/language/src/Form/ContentLanguageSettingsForm.php +29 −2 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ use Drupal\Core\Entity\ContentEntityTypeInterface; use Drupal\Core\Entity\EntityTypeBundleInfoInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormStateInterface; use Drupal\language\Entity\ContentLanguageSettings; Loading Loading @@ -38,6 +39,13 @@ class ContentLanguageSettingsForm extends FormBase { */ protected $multipleCapable = TRUE; /** * The module handler. * * @var \Drupal\Core\Extension\ModuleHandlerInterface */ protected $moduleHandler; /** * Constructs an \Drupal\views\Plugin\views\argument_validator\Entity object. * Loading @@ -45,10 +53,13 @@ class ContentLanguageSettingsForm extends FormBase { * The entity type manager. * @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $entity_type_bundle_info * The entity type bundle info. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler. */ public function __construct(EntityTypeManagerInterface $entity_type_manager, EntityTypeBundleInfoInterface $entity_type_bundle_info) { public function __construct(EntityTypeManagerInterface $entity_type_manager, EntityTypeBundleInfoInterface $entity_type_bundle_info, ModuleHandlerInterface $module_handler) { $this->entityTypeManager = $entity_type_manager; $this->entityTypeBundleInfo = $entity_type_bundle_info; $this->moduleHandler = $module_handler; } /** Loading @@ -57,10 +68,26 @@ public function __construct(EntityTypeManagerInterface $entity_type_manager, Ent public static function create(ContainerInterface $container) { return new static( $container->get('entity_type.manager'), $container->get('entity_type.bundle.info') $container->get('entity_type.bundle.info'), $container->get('module_handler') ); } /** * The _title_callback for the language.content_settings_page route. * * @return \Drupal\Core\StringTranslation\TranslatableMarkup * The page title. */ public function getTitle(): string { if ($this->moduleHandler->moduleExists('content_translation')) { return $this->t('Content language and translation'); } else { return $this->t('Content language'); } } /** * {@inheritdoc} */ Loading core/modules/language/tests/src/Functional/LanguageSelectorTranslatableTest.php +14 −0 Original line number Diff line number Diff line Loading @@ -91,4 +91,18 @@ public function testLanguageStringSelector() { $this->assertSame($name_translation, $option->getText()); } /** * Tests that correct title is displayed for content translation page. */ public function testContentTranslationPageTitle() { $this->drupalGet('admin/config/regional/content-language'); $this->assertSession()->pageTextContains('Content language and translation'); $this->assertSession()->pageTextNotMatches('#Content language$#'); \Drupal::service('module_installer')->uninstall(['content_translation']); $this->drupalGet('admin/config/regional/content-language'); $this->assertSession()->pageTextContains('Content language'); $this->assertSession()->pageTextNotContains('Content language and translation'); } } Loading
core/modules/language/language.routing.yml +1 −1 Original line number Diff line number Diff line Loading @@ -81,7 +81,7 @@ language.negotiation_browser_delete: language.content_settings_page: path: '/admin/config/regional/content-language' defaults: _title: 'Content language' _title_callback: '\Drupal\language\Form\ContentLanguageSettingsForm::getTitle' _form: '\Drupal\language\Form\ContentLanguageSettingsForm' requirements: _permission: 'administer languages'
core/modules/language/src/Form/ContentLanguageSettingsForm.php +29 −2 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ use Drupal\Core\Entity\ContentEntityTypeInterface; use Drupal\Core\Entity\EntityTypeBundleInfoInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormStateInterface; use Drupal\language\Entity\ContentLanguageSettings; Loading Loading @@ -38,6 +39,13 @@ class ContentLanguageSettingsForm extends FormBase { */ protected $multipleCapable = TRUE; /** * The module handler. * * @var \Drupal\Core\Extension\ModuleHandlerInterface */ protected $moduleHandler; /** * Constructs an \Drupal\views\Plugin\views\argument_validator\Entity object. * Loading @@ -45,10 +53,13 @@ class ContentLanguageSettingsForm extends FormBase { * The entity type manager. * @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $entity_type_bundle_info * The entity type bundle info. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler. */ public function __construct(EntityTypeManagerInterface $entity_type_manager, EntityTypeBundleInfoInterface $entity_type_bundle_info) { public function __construct(EntityTypeManagerInterface $entity_type_manager, EntityTypeBundleInfoInterface $entity_type_bundle_info, ModuleHandlerInterface $module_handler) { $this->entityTypeManager = $entity_type_manager; $this->entityTypeBundleInfo = $entity_type_bundle_info; $this->moduleHandler = $module_handler; } /** Loading @@ -57,10 +68,26 @@ public function __construct(EntityTypeManagerInterface $entity_type_manager, Ent public static function create(ContainerInterface $container) { return new static( $container->get('entity_type.manager'), $container->get('entity_type.bundle.info') $container->get('entity_type.bundle.info'), $container->get('module_handler') ); } /** * The _title_callback for the language.content_settings_page route. * * @return \Drupal\Core\StringTranslation\TranslatableMarkup * The page title. */ public function getTitle(): string { if ($this->moduleHandler->moduleExists('content_translation')) { return $this->t('Content language and translation'); } else { return $this->t('Content language'); } } /** * {@inheritdoc} */ Loading
core/modules/language/tests/src/Functional/LanguageSelectorTranslatableTest.php +14 −0 Original line number Diff line number Diff line Loading @@ -91,4 +91,18 @@ public function testLanguageStringSelector() { $this->assertSame($name_translation, $option->getText()); } /** * Tests that correct title is displayed for content translation page. */ public function testContentTranslationPageTitle() { $this->drupalGet('admin/config/regional/content-language'); $this->assertSession()->pageTextContains('Content language and translation'); $this->assertSession()->pageTextNotMatches('#Content language$#'); \Drupal::service('module_installer')->uninstall(['content_translation']); $this->drupalGet('admin/config/regional/content-language'); $this->assertSession()->pageTextContains('Content language'); $this->assertSession()->pageTextNotContains('Content language and translation'); } }