diff -u b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php --- b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php +++ b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php @@ -526,7 +526,7 @@ 'source_module' => 'taxonomy', 'destination_module' => 'taxonomy', ], - 'd6_i18n_taxonomy_vocabulary' => [ + 'd6_taxonomy_vocabulary_translation' => [ 'source_module' => 'i18n', 'destination_module' => 'taxonomy', ], reverted: --- b/core/modules/taxonomy/migration_templates/d6_i18n_taxonomy_vocabulary.yml +++ /dev/null @@ -1,27 +0,0 @@ -id: d6_i18n_taxonomy_vocabulary -label: Taxonomy vocabularies -migration_tags: - - Drupal 6 -source: - plugin: d6_i18n_taxonomy_vocabulary -process: - vid: - - - plugin: machine_name - source: name - - - plugin: substr - length: 32 - langcode: language - property: - plugin: static_map - source: property - map: - name: name - description: description - translation: translation -destination: - plugin: entity:taxonomy_vocabulary -migration_dependencies: - required: - - d6_taxonomy_vocabulary reverted: --- b/core/modules/taxonomy/src/Plugin/migrate/source/d6/I18nTaxonomyVocabulary.php +++ /dev/null @@ -1,68 +0,0 @@ -select('vocabulary', 'v') - ->fields('v', ['vid', 'name', 'description']) - ->fields('i18n', ['lid', 'type', 'property', 'objectid']) - ->fields('lt', ['lid', 'translation']) - ->condition('i18n.type', 'vocabulary'); - $query->addField('lt', 'language', 'language'); - // The vid is an integer and the objectid is a string. Use the like operator - // to force PostgreSQL to cast the vid to a string. - $query->join('i18n_strings', 'i18n', 'v.vid like i18n.objectid'); - $query->leftJoin('locales_target', 'lt', 'lt.lid = i18n.lid'); - - return $query; - } - /** - * {@inheritdoc} - */ - public function fields() { - return [ - 'vid' => $this->t('The vocabulary ID.'), - 'language' => $this->t('Language for this field.'), - 'property' => $this->t('Name of property being translated.'), - 'translation' => $this->t('Translation of either the title or explanation.') - ]; - } - - /** - * {@inheritdoc} - */ - public function getIds() { - $ids['vid']['type'] = 'integer'; - return $ids; - } - -} reverted: --- b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateI18nTaxonomyVocabularyTest.php +++ /dev/null @@ -1,47 +0,0 @@ -executeMigrations([ - 'd6_taxonomy_vocabulary', - 'd6_i18n_taxonomy_vocabulary', - ]); - } - - /** - * Tests the Drupal 6 i18n taxonomy vocabularies to Drupal 8 migration. - */ - public function testI18nTaxonomyVocabulary() { - $language_manager = \Drupal::service('language_manager'); - $config = $language_manager->getLanguageConfigOverride('fr', 'taxonomy.vocabulary.vocabulary_1_i_0_'); - $this->assertSame('fr - vocabulary 1 (i=0)', $config->get('name')); - $config = $language_manager->getLanguageConfigOverride('fr', 'taxonomy.vocabulary.vocabulary_2_i_1_'); - $this->assertSame('fr - vocabulary 2 (i=1)', $config->get('name')); - $config = $language_manager->getLanguageConfigOverride('fr', 'taxonomy.vocabulary.vocabulary_3_i_2_'); - $this->assertSame('fr - vocabulary 3 (i=2)', $config->get('name')); - $config = $language_manager->getLanguageConfigOverride('fr', 'taxonomy.vocabulary.vocabulary_name_much_longer_than'); - $this->assertSame('Nom de vocabulaire beaucoup plus long que trente-deux caractères', $config->get('name')); - $config = $language_manager->getLanguageConfigOverride('fr', 'taxonomy.vocabulary.tags'); - $this->assertSame('fr - Tags', $config->get('name')); - } - -} reverted: --- b/core/modules/taxonomy/tests/src/Kernel/Plugin/migrate/source/d6/I18nVocabularyTest.php +++ /dev/null @@ -1,131 +0,0 @@ - 1, - 'objectid' => 1, - 'type' => 'vocabulary', - 'property' => 'name', - 'objectindex' => 1, - 'format' => 0, - ], - [ - 'lid' => 2, - 'objectid' => 2, - 'type' => 'vocabulary', - 'property' => 'name', - 'objectindex' => 2, - 'format' => 0, - ], - ]; - - protected $locales_target = [ - [ - 'lid' => 1, - 'language' => 'fr', - 'translation' => 'fr - vocabulary 1', - 'plid' => 0, - 'plural' => 0, - 'i18n_status' => 0, - ], - [ - 'lid' => 2, - 'language' => 'fr', - 'translation' => 'fr - vocabulary 2', - 'plid' => 0, - 'plural' => 0, - 'i18n_status' => 0, - ], - ]; - - protected $vocabulary = [ - [ - 'vid' => 1, - 'name' => 'vocabulary 1', - 'description' => 'description of vocabulary 1', - 'help' => 1, - 'relations' => 1, - 'hierarchy' => 1, - 'multiple' => 0, - 'required' => 0, - 'tags' => 0, - 'module' => 'taxonomy', - 'weight' => 4, - 'language' => '' - ], - [ - 'vid' => 2, - 'name' => 'vocabulary 2', - 'description' => 'description of vocabulary 2', - 'help' => 1, - 'relations' => 1, - 'hierarchy' => 1, - 'multiple' => 0, - 'required' => 0, - 'tags' => 0, - 'module' => 'taxonomy', - 'weight' => 5, - 'language' => '' - ], - ]; - - protected $expectedResults = [ - [ - 'vid' => 1, - 'name' => 'vocabulary 1', - 'description' => 'description of vocabulary 1', - 'lid' => '1', - 'type' => 'vocabulary', - 'property' => 'name', - 'objectid' => '1', - 'lt_lid' => '1', - 'translation' => 'fr - vocabulary 1', - 'language' => 'fr', - ], - [ - 'vid' => 2, - 'name' => 'vocabulary 2', - 'description' => 'description of vocabulary 2', - 'lid' => '2', - 'type' => 'vocabulary', - 'property' => 'name', - 'objectid' => '2', - 'lt_lid' => '2', - 'translation' => 'fr - vocabulary 2', - 'language' => 'fr', - ], - ]; - - /** - * {@inheritdoc} - */ - public function providerSource() { - $tests = []; - - $tests[0][0]['i18n_strings'] = $this->i18n_strings; - $tests[0][0]['locales_target'] = $this->locales_target; - $tests[0][0]['vocabulary'] = $this->vocabulary; - - $tests[0][1] = $this->expectedResults; - - return $tests; - } - -} only in patch2: unchanged: --- /dev/null +++ b/core/modules/taxonomy/migration_templates/d6_taxonomy_vocabulary_translation.yml @@ -0,0 +1,27 @@ +id: d6_taxonomy_vocabulary_translation +label: Taxonomy vocabularies +migration_tags: + - Drupal 6 +source: + plugin: d6_taxonomy_vocabulary_translation +process: + vid: + - + plugin: machine_name + source: name + - + plugin: substr + length: 32 + langcode: language + property: + plugin: static_map + source: property + map: + name: name + description: description + translation: translation +destination: + plugin: entity:taxonomy_vocabulary +migration_dependencies: + required: + - d6_taxonomy_vocabulary only in patch2: unchanged: --- /dev/null +++ b/core/modules/taxonomy/src/Plugin/migrate/source/d6/TaxonomyVocabularyTranslation.php @@ -0,0 +1,68 @@ +select('vocabulary', 'v') + ->fields('v', ['vid', 'name', 'description']) + ->fields('i18n', ['lid', 'type', 'property', 'objectid']) + ->fields('lt', ['lid', 'translation']) + ->condition('i18n.type', 'vocabulary'); + $query->addField('lt', 'language', 'language'); + // The vid is an integer and the objectid is a string. Use the like operator + // to force PostgreSQL to cast the vid to a string. + $query->join('i18n_strings', 'i18n', 'v.vid like i18n.objectid'); + $query->leftJoin('locales_target', 'lt', 'lt.lid = i18n.lid'); + + return $query; + } + /** + * {@inheritdoc} + */ + public function fields() { + return [ + 'vid' => $this->t('The vocabulary ID.'), + 'language' => $this->t('Language for this field.'), + 'property' => $this->t('Name of property being translated.'), + 'translation' => $this->t('Translation of either the title or explanation.') + ]; + } + + /** + * {@inheritdoc} + */ + public function getIds() { + $ids['vid']['type'] = 'integer'; + return $ids; + } + +} only in patch2: unchanged: --- /dev/null +++ b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTaxonomyVocabularyTranslationTest.php @@ -0,0 +1,47 @@ +executeMigrations([ + 'd6_taxonomy_vocabulary', + 'd6_taxonomy_vocabulary_translation', + ]); + } + + /** + * Tests the Drupal 6 i18n taxonomy vocabularies to Drupal 8 migration. + */ + public function testTaxonomyVocabularyTranslation() { + $language_manager = \Drupal::service('language_manager'); + $config = $language_manager->getLanguageConfigOverride('fr', 'taxonomy.vocabulary.vocabulary_1_i_0_'); + $this->assertSame('fr - vocabulary 1 (i=0)', $config->get('name')); + $config = $language_manager->getLanguageConfigOverride('fr', 'taxonomy.vocabulary.vocabulary_2_i_1_'); + $this->assertSame('fr - vocabulary 2 (i=1)', $config->get('name')); + $config = $language_manager->getLanguageConfigOverride('fr', 'taxonomy.vocabulary.vocabulary_3_i_2_'); + $this->assertSame('fr - vocabulary 3 (i=2)', $config->get('name')); + $config = $language_manager->getLanguageConfigOverride('fr', 'taxonomy.vocabulary.vocabulary_name_much_longer_than'); + $this->assertSame('Nom de vocabulaire beaucoup plus long que trente-deux caractères', $config->get('name')); + $config = $language_manager->getLanguageConfigOverride('fr', 'taxonomy.vocabulary.tags'); + $this->assertSame('fr - Tags', $config->get('name')); + } + +} only in patch2: unchanged: --- /dev/null +++ b/core/modules/taxonomy/tests/src/Kernel/Plugin/migrate/source/d6/VocabularyTranslationTest.php @@ -0,0 +1,131 @@ + 1, + 'objectid' => 1, + 'type' => 'vocabulary', + 'property' => 'name', + 'objectindex' => 1, + 'format' => 0, + ], + [ + 'lid' => 2, + 'objectid' => 2, + 'type' => 'vocabulary', + 'property' => 'name', + 'objectindex' => 2, + 'format' => 0, + ], + ]; + + protected $locales_target = [ + [ + 'lid' => 1, + 'language' => 'fr', + 'translation' => 'fr - vocabulary 1', + 'plid' => 0, + 'plural' => 0, + 'i18n_status' => 0, + ], + [ + 'lid' => 2, + 'language' => 'fr', + 'translation' => 'fr - vocabulary 2', + 'plid' => 0, + 'plural' => 0, + 'i18n_status' => 0, + ], + ]; + + protected $vocabulary = [ + [ + 'vid' => 1, + 'name' => 'vocabulary 1', + 'description' => 'description of vocabulary 1', + 'help' => 1, + 'relations' => 1, + 'hierarchy' => 1, + 'multiple' => 0, + 'required' => 0, + 'tags' => 0, + 'module' => 'taxonomy', + 'weight' => 4, + 'language' => '' + ], + [ + 'vid' => 2, + 'name' => 'vocabulary 2', + 'description' => 'description of vocabulary 2', + 'help' => 1, + 'relations' => 1, + 'hierarchy' => 1, + 'multiple' => 0, + 'required' => 0, + 'tags' => 0, + 'module' => 'taxonomy', + 'weight' => 5, + 'language' => '' + ], + ]; + + protected $expectedResults = [ + [ + 'vid' => 1, + 'name' => 'vocabulary 1', + 'description' => 'description of vocabulary 1', + 'lid' => '1', + 'type' => 'vocabulary', + 'property' => 'name', + 'objectid' => '1', + 'lt_lid' => '1', + 'translation' => 'fr - vocabulary 1', + 'language' => 'fr', + ], + [ + 'vid' => 2, + 'name' => 'vocabulary 2', + 'description' => 'description of vocabulary 2', + 'lid' => '2', + 'type' => 'vocabulary', + 'property' => 'name', + 'objectid' => '2', + 'lt_lid' => '2', + 'translation' => 'fr - vocabulary 2', + 'language' => 'fr', + ], + ]; + + /** + * {@inheritdoc} + */ + public function providerSource() { + $tests = []; + + $tests[0][0]['i18n_strings'] = $this->i18n_strings; + $tests[0][0]['locales_target'] = $this->locales_target; + $tests[0][0]['vocabulary'] = $this->vocabulary; + + $tests[0][1] = $this->expectedResults; + + return $tests; + } + +}