diff --git a/core/modules/block/migration_templates/d6_block_translation.yml b/core/modules/block/migration_templates/d6_block_translation.yml new file mode 100644 index 0000000..a6ebf38 --- /dev/null +++ b/core/modules/block/migration_templates/d6_block_translation.yml @@ -0,0 +1,64 @@ +id: d6_block_translation +label: Block translations +migration_tags: + - Drupal 6 +source: + plugin: d6_block_translation + constants: + dest_label: 'settings/label' +process: + langcode: language + property: constants/dest_label + translation: title + id: + plugin: migration + migration: d6_block + source: + - module + - delta + plugin: + - + plugin: static_map + bypass: true + source: + - module + - delta + map: + book: + 0: book_navigation + comment: + 0: views_block:comments_recent-block_1 + forum: + 0: forum_active_block + 1: forum_new_block + locale: + 0: language_block + node: + 0: node_syndicate_block + search: + 0: search_form_block + statistics: + 0: statistics_popular_block + system: + 0: system_powered_by_block + user: + 0: user_login_block + 1: system_menu_block:tools + 2: views_block:who_s_new-block_1 + 3: views_block:who_s_online-who_s_online_block + - + plugin: block_plugin_id + - + plugin: skip_on_empty + method: row + theme: + plugin: block_theme + source: + - theme + - default_theme + - admin_theme +destination: + plugin: entity:block +migration_dependencies: + required: + - d6_block diff --git a/core/modules/block/src/Plugin/migrate/source/d6/BlockTranslation.php b/core/modules/block/src/Plugin/migrate/source/d6/BlockTranslation.php new file mode 100644 index 0000000..7e1b48a --- /dev/null +++ b/core/modules/block/src/Plugin/migrate/source/d6/BlockTranslation.php @@ -0,0 +1,50 @@ +fields('i18n', ['ibid', 'module', 'delta', 'type', 'language']) + ->fields('b', ['bid', 'theme', 'title']); + $query->addField('b', 'module', 'block_module'); + $query->addField('b', 'delta', 'block_delta'); + $query->innerJoin('i18n_blocks', 'i18n', ('b.module = i18n.module AND b.delta = i18n.delta')); + return $query; + } + + /** + * {@inheritdoc} + */ + public function fields() { + $fields = parent::fields(); + $fields['language'] = $this->t('Language for this field.'); + return $fields; + } + + /** + * {@inheritdoc} + */ + public function getIds() { + $ids = parent::getIds(); + $ids['module']['alias'] = 'b'; + $ids['delta']['alias'] = 'b'; + $ids['language']['type'] = 'string'; + return $ids; + } + +} diff --git a/core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockContentTranslationTest.php b/core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockContentTranslationTest.php new file mode 100644 index 0000000..e20a013 --- /dev/null +++ b/core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockContentTranslationTest.php @@ -0,0 +1,60 @@ +installConfig(['block']); + $this->installConfig(['block_content']); + $this->installEntitySchema('block_content'); + + $this->executeMigrations([ + 'd6_filter_format', + 'block_content_type', + 'block_content_body_field', + 'd6_custom_block', + 'd6_user_role', + 'd6_block', + 'd6_block_translation', + ]); + block_rebuild(); + } + + /** + * Tests the migration of block title translation. + */ + public function testBlockContentTranslation() { + $config = \Drupal::service('language_manager')->getLanguageConfigOverride('zu', 'block.block.user_1'); + $this->assertSame('zu - Test Title 02', $config->get('settings.label')); + } + +} diff --git a/core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockTest.php b/core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockTest.php index bb59f50..c78dc57 100644 --- a/core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockTest.php +++ b/core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockTest.php @@ -116,9 +116,9 @@ public function testBlockMigration() { $visibility = []; $settings = [ 'id' => 'system_menu_block', - 'label' => '', + 'label' => 'zu - Test Title 02', 'provider' => 'system', - 'label_display' => '0', + 'label_display' => 'visible', 'level' => 1, 'depth' => 0, ]; diff --git a/core/modules/block/tests/src/Kernel/Plugin/migrate/source/d6/BlockTranslationTest.php b/core/modules/block/tests/src/Kernel/Plugin/migrate/source/d6/BlockTranslationTest.php new file mode 100644 index 0000000..166f89a --- /dev/null +++ b/core/modules/block/tests/src/Kernel/Plugin/migrate/source/d6/BlockTranslationTest.php @@ -0,0 +1,95 @@ + 1, + 'module' => 'user', + 'delta' => '1', + 'theme' => 'garland', + 'status' => 1, + 'weight' => 0, + 'region' => 'left', + 'visibility' => 0, + 'pages' => '', + 'title' => 'fr - Test Title 01', + 'cache' => -1, + ], + [ + 'bid' => 2, + 'module' => 'user', + 'delta' => '2', + 'theme' => 'garland', + 'status' => 1, + 'weight' => 5, + 'region' => 'right', + 'visibility' => 0, + 'pages' => '', + 'title' => 'zu - Test Title 02', + 'cache' => -1, + ], + ]; + + $tests[0]['source_data']['i18n_blocks'] = [ + [ + 'ibid' => 1, + 'module' => 'user', + 'delta' => '1', + 'type' => 0, + 'language' => 'fr', + ], + [ + 'ibid' => 2, + 'module' => 'user', + 'delta' => '2', + 'type' => 0, + 'language' => 'zu', + ], + ]; + + // The expected results. + $tests[0]['expected_data'] = [ + [ + 'bid' => 1, + 'module' => 'user', + 'delta' => '1', + 'title' => 'fr - Test Title 01', + 'ibid' => 1, + 'type' => '0', + 'language' => 'fr', + ], + [ + 'bid' => 2, + 'module' => 'user', + 'delta' => '2', + 'theme' => 'garland', + 'title' => 'zu - Test Title 02', + 'ibid' => 2, + 'type' => '0', + 'language' => 'zu', + ], + ]; + + return $tests; + } + +} diff --git a/core/modules/migrate_drupal/tests/fixtures/drupal6.php b/core/modules/migrate_drupal/tests/fixtures/drupal6.php index 4ca588b..1afc5b3 100644 --- a/core/modules/migrate_drupal/tests/fixtures/drupal6.php +++ b/core/modules/migrate_drupal/tests/fixtures/drupal6.php @@ -746,7 +746,7 @@ 'throttle' => '0', 'visibility' => '0', 'pages' => '', - 'title' => '', + 'title' => 'zu - Test Title 02', 'cache' => '-1', )) ->values(array( @@ -8530,6 +8530,23 @@ 'mysql_character_set' => 'utf8', )); +$connection->insert('i18n_blocks') +->fields(array( + 'ibid', + 'module', + 'delta', + 'type', + 'language', +)) +->values(array( + 'ibid' => '1', + 'module' => 'user', + 'delta' => '1', + 'type' => '0', + 'language' => 'zu', +)) +->execute(); + $connection->schema()->createTable('i18n_strings', array( 'fields' => array( 'lid' => array(