Problem/Motivation

I cannot find documentation about configuring a Feed type to import a multilingual entity. For example, in the JSON source I have, there are translations with same NID (same content, different languages). I tried the mapping of the attached screenshot but after import, only the first translation is imported (the first translation with same NID).

Moreover, If I uncheck the unique checkbox, all node translations get imported. However, they are created as separated nodes (without having the same NID they had on original source).

Proposed resolution

Document how to proceed with multilingual imports in the official docs:
https://www.drupal.org/docs/contributed-modules/feeds

The docs would need to say what workflows for importing multilingual content are supported and then provide a step by step guide on how to implement each workflow.

One workflow is that the source looks like this, where the columns specify the language:

id,title_en,title_nl
1,Hello World,Hallo Wereld

An other workflow where the language is specified in a particular column:

id,title,langcode
1,Hello World,en
1,Hallo Wereld,nl

And a third workflow is that the content is in separate files:
content_en.csv:

id,title
1,Hello World

content_nl.csv:

id,title
1,Hallo Wereld

And this guide should then explain how one can become a translation of the other.

CommentFileSizeAuthor
#6 feeds-multilingual-mapping.png99.52 KBjmee
mapping.png79.65 KBrcodina

Comments

rcodina created an issue. See original summary.

rcodina’s picture

Issue summary: View changes
rcodina’s picture

Issue summary: View changes
rcodina’s picture

Issue summary: View changes
rcodina’s picture

Issue summary: View changes
jmee’s picture

StatusFileSize
new99.52 KB

I got this working based on hints in comment #2 in this issue: A translation already exists for the specified language

I was originally trying to import translations as separate items (thinking that the block would be created in one language and updated with a translation via a second feed item), but it seems as though they need to be grouped together and the language should be set in the field mapping.

I can provide an example of a block import via csv, but it should be similar for other types of entities and importers. Custom blocks are very simple, with just two fields on the default 'Basic block' block type (info and body).

I've attached a screenshot of the mapping settings. The site has english and french installed, with english configured as the 'default' language.

csv (successfully imported!):

info;info fr;body text;body text fr;bid
My block;Mon bloc;This is my block! Isn’t it great!;Voici mon bloc! C’est super!;2100

I'm not actually mapping anything to langcode or the default language values, it seems like that is meant for a different context (when we're not importing content that already has a translation ?).

And here is the config for my feed type:

langcode: en
status: true
dependencies:
  config:
    - block_content.type.basic
    - core.base_field_override.block_content.basic.info
    - field.field.block_content.basic.body
  module:
    - block_content
label: 'Block import'
id: block_import
description: 'Import block content to custom blocks library'
help: ''
import_period: -1
fetcher: upload
fetcher_configuration:
  allowed_extensions: 'txt csv tsv xml opml'
  directory: 'private://feeds'
parser: csv
parser_configuration:
  delimiter: ;
  no_headers: false
  line_limit: 100
processor: 'entity:block_content'
processor_configuration:
  values:
    type: basic
  langcode: en
  insert_new: 1
  update_existing: 2
  update_non_existent: _keep
  skip_hash_check: false
  authorize: false
  revision: true
  expire: -1
  owner_feed_author: false
  owner_id: 0
custom_sources:
  info:
    value: info
    label: info
    machine_name: info
  body_text:
    value: 'body text'
    label: 'body text'
    machine_name: body_text
  language:
    value: 'content language'
    label: 'content language'
    machine_name: language
  default_translation:
    value: 'default translation'
    label: 'default translation'
    machine_name: default_translation
  bid:
    value: bid
    label: bid
    machine_name: bid
  translation_source:
    value: 'translation source'
    label: 'translation source'
    machine_name: translation_source
  body_text_fr:
    value: 'body text fr'
    label: 'body text fr'
    machine_name: body_text_fr
  info_fr:
    value: 'info fr'
    label: 'info fr'
    machine_name: info_fr
mappings:
  -
    target: info
    map:
      value: info
    settings:
      language: en
    unique: {  }
  -
    target: body
    map:
      value: body_text
      summary: ''
    settings:
      language: en
      format: plain_text
  -
    target: id
    map:
      value: bid
    settings: {  }
    unique:
      value: '1'
  -
    target: body
    map:
      value: body_text_fr
      summary: ''
    settings:
      language: fr
      format: plain_text
  -
    target: info
    map:
      value: info_fr
    settings:
      language: fr
    unique: {  }
megachriz’s picture

Issue summary: View changes
Issue tags: +multilanguage

Tagging issue with "multilanguage", so I can find this issue back as soon as I plan to focus on Feeds multilingual issues again.

I also updated the issue summary, specifying three workflows that should be documented.

megachriz’s picture

Issue summary: View changes
ptmkenny’s picture

Some additional documentation in comments #8 and #9 on this issue.

wheelercreek’s picture

I also had do this and it was tricky to figure out. I wrote up a blog post to capture my process. Feel free to use anything I wrote here in the official documentation. https://www.wheelercreek.com/blog/use-feeds-module-multilingual-data-imp...

sandeshyadav’s picture

Thank you @wheelercreek. Your blog saved my day :)