diff --git a/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php b/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php index 13890c0..b03a9d2 100644 --- a/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php +++ b/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php @@ -432,6 +432,33 @@ public function testNodeTypeTranslation() { } /** + * Tests the node type title label translation. + */ + public function testNodeTypeTitleLabelTranslation() { + $type = Unicode::strtolower($this->randomMachineName(16)); + $name = $this->randomString(); + $this->drupalLogin($this->adminUser); + $this->drupalCreateContentType(array('type' => $type, 'name' => $name)); + + // Edit the title label for it to be displayed on the translation form. + $this->drupalPostForm("admin/structure/types/manage/$type", array('title_label' => 'Edited title'), t('Save content type')); + + // Assert that the title label is displayed on the translation form with the right value. + $this->drupalGet("admin/structure/types/manage/$type/translate/fr/add"); + $this->assertRaw(t('Label')); + $this->assertRaw(t('Edited title')); + + // Translate the title label. + $this->drupalPostForm(NULL, array("translation[config_names][core.base_field_override.node.$type.title][label]" => 'Translated title'), t('Save translation')); + + // Assert that the right title label is displayed on the node add form. + $this->drupalGet("node/add/$type"); + $this->assertRaw(t('Edited title')); + $this->drupalGet("fr/node/add/$type"); + $this->assertRaw(t('Translated title')); + } + + /** * Tests date format translation. */ public function testDateFormatTranslation() { diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 7c371d6..e74327f 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -1340,3 +1340,10 @@ function node_comment_delete($comment) { node_reindex_node_search($comment->getCommentedEntityId()); } } + +/** + * Implements hook_config_translation_info_alter(). + */ +function node_config_translation_info_alter(&$info) { + $info['node_type']['class'] = 'Drupal\node\ConfigTranslation\NodeTypeMapper'; +} diff --git a/core/modules/node/src/ConfigTranslation/NodeTypeMapper.php b/core/modules/node/src/ConfigTranslation/NodeTypeMapper.php new file mode 100644 index 0000000..be0cdb8 --- /dev/null +++ b/core/modules/node/src/ConfigTranslation/NodeTypeMapper.php @@ -0,0 +1,29 @@ +id(); + $this->addConfigName("core.base_field_override.node.$node_type.title"); + } + +}