gpt4 book ai didi

Drupal 7 到 Drupal 8 : migrate taxonomy with translation (i18n)?

转载 作者:行者123 更新时间:2023-12-01 14:24:06 27 4
gpt4 key购买 nike

Drupal 7 到 Drupal 8 的迁移。我已经迁移了源语言的术语,但我无法迁移术语的翻译 (i18n) - 名称和描述。

我创建了一个自定义源插件,我在其中创建了带有分类法名称和描述翻译的新字段。

那么如何迁移术语翻译呢? D6 示例不起作用。

谢谢。

最佳答案

您可以在完全迁移分类法后执行这些步骤(无需翻译):

  1. 安装语言 - https://www.drupal.org/docs/8/multilingual/install-a-language
  2. 创建迁移模块(节点示例):https://github.com/evolvingweb/migrate_example_i18n
  3. 编写迁移源插件(节点示例):https://github.com/evolvingweb/migrate_example_i18n/blob/8.x/src/Plugin/migrate/source/D7NodeEntityTranslation.php
  4. 用“映射”编写 YUML 文件(节点示例):https://github.com/evolvingweb/migrate_example_i18n/blob/8.x/config/install/migrate_plus.migration.example_dog_i18n.yml
  5. 在命令行提示符下,在项目文件夹中执行以下命令:drush mim module_name

我的过程术语的 yuml 片段没有反式:

  # 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

我的 i18n trans yuml 被剪掉了:

来源:

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

i18n 翻译查询的源文件片段:

     $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']);

更多信息: https://events.drupal.org/sites/default/files/slides/Migrating%20Multilingual%20Content%20to%20Drupal%208.pdf

关于Drupal 7 到 Drupal 8 : migrate taxonomy with translation (i18n)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49278215/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com