3

Drupal 7 to Drupal 8 migration. I've migrated terms in the source language, but I'm unable to migrate term's translations (i18n) - name and description.

I've created a custom source plugin, where I create new fields with translations for taxonomy name and description.

So how to migrate term translations? D6 example doesn't work.

Thank you.

apaderno
  • 28,547
  • 16
  • 75
  • 90

2 Answers2

0

You could perform these steps after a full migration of your taxonomy (without translation):

  1. Install the language - https://www.drupal.org/docs/8/multilingual/install-a-language
  2. Create a module for migration (example for node): https://github.com/evolvingweb/migrate_example_i18n
  3. Write a Migration Source Plugin (example for node): https://github.com/evolvingweb/migrate_example_i18n/blob/8.x/src/Plugin/migrate/source/D7NodeEntityTranslation.php
  4. Write YUML file with "mapping" (example for node): https://github.com/evolvingweb/migrate_example_i18n/blob/8.x/config/install/migrate_plus.migration.example_dog_i18n.yml
  5. At a command-line prompt, in the project folder, execute the following: drush mim module_name

My yuml snippet of process term without trans:

  # to_db_value : from_db_value.
  # d8_db_value : d7_db_value
  tid: tid
  vid:
   plugin: migration_lookup
   migration: your_vocabulary_migration
   source: vid
  langcode:
   plugin: default_value
   default_value: en // your und lng

my i18n trans yuml snipped:

source:

plugin: taxonomy_terms_i18n // custom source plugin to get translations
  translations: true
destination:
  plugin: entity:taxonomy_term
  translations: true
process:
  # to_db_value : from_db_value.
  # d8_db_value : d7_db_value
  tid:
    plugin: migration_lookup
    migration: // name of your previous migration of terms
    source: tid
  langcode:
    plugin: default_value
    default_value: es
  vid:
    plugin: skip_on_value
    source: machine_name
    method: row
    value:
      - // terms vid that you don't need
  name:
    plugin: skip_on_empty
    method: row
    source: translation

source file snipped of query for i18n translate:

     $query = $this->select('taxonomy_term_data', 'term_data');
 $query->join('taxonomy_vocabulary','vocabulary', 'term_data.vid = vocabulary.vid');
 $query->leftJoin('i18n_string','i18n', 'term_data.tid = i18n.objectid');
 $query->leftJoin('locales_target','locales', 'i18n.lid = locales.lid');

 $query
 ->fields('term_data', [
   'tid',
   'vid',
   'name',
   'description',
   'weight',
   'format',
 ])
 ->fields('vocabulary', ['machine_name'])
 ->fields('locales', ['translation']);

More info: https://events.drupal.org/sites/default/files/slides/Migrating%20Multilingual%20Content%20to%20Drupal%208.pdf

mialdi98
  • 58
  • 7
0

You can import Taxonomies, Nodes, Users, Products, Custom Blocks, Paragraphs, Custom Menu Links with FEEDS MODULE.

For importing field's multiple values you also need module called FEEDS TAMPER.

user229044
  • 232,980
  • 40
  • 330
  • 338
Alen Simonyan
  • 360
  • 2
  • 9