CommentFileSizeAuthor
#8 mapping-translation-feed.JPG43.04 KBmarksmith

Comments

Anybody created an issue. See original summary.

anybody’s picture

Issue summary: View changes
megachriz’s picture

@Anybody
Yes, it is possible. And there are different ways to do it. But since I don't do multilingual imports myself often, I don't have a step by step explanation ready on how to do it. What I remember is the following:

  1. You can configure a feed type to only import for a single language and then create a feed type per language.
  2. You can configure a feed type to import data for multiple languages at once, in case of CSV you would then have title_en, title_de, title_nl, etcetera. The title target would then appear more than once on the mapping page, each time with a different language configured.
  3. You can let the source specify which language each item is in, so in your CSV you would then have a column called 'langcode' (or something similar). If a row contains English values, then the langcode for that row is 'en', if it contains German it would be 'de', etcetera. However, this method has a known issue: #3126351: A translation already exists for the specified language

Finally, I know that there are some issues with multilingual imports, these are noted on https://www.drupal.org/project/feeds/issues/1960800#feeds-i18n.

This is what I wrote about multilingual support on the release notes of 8.x-3.0-alpha7:

Support for importing content translations has finally be added! You can now either configure on the target or on the processor in which language you want to import values. Configure it on the processor if the language for all source values is the same, configure it on the target if the language differs per target. You can also configure the language on both, then the language configured on a target overrides the language configured on the processor.

Content translation imports has been tested for various cases, but since it was a complex thing to add, we do expect issues to arise in some cases. One issue has been noticed when using the target "Language (langcode)": #3126351: A translation already exists for the specified language. The question yet to answer is how this issue exactly occurs.

There is also an other issue open in which documentation is requested: #3256925: Document how to import multilingual content. So perhaps we should close this one as a duplicate?

megachriz’s picture

@Anybody
If you can sort out all different possibilities and write a step-by-step guide, that would be great!

anybody’s picture

@MegaChriz thank you very, very much for your detailed reply! Great as always!

I'll try to, but can't guarantee it currently, as I'm busy in many projects, so if anyone from the community (perhaps even a non-developer) could pick this up, that would be great.

Yes, we can close this as duplicate, but perhaps the information on the module page feature list should already be added?

megachriz’s picture

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.

Leif_S’s picture

@MegaChriz: Just wanted to add that I am also very interested in importing content to different languages/translation sets

marksmith’s picture

StatusFileSize
new43.04 KB

After many trials, I have found a way to import multilingual content by Feeds. Since it appeared to me pretty complex to achieve, I share this with everyone looking for a solution. I imported multilingual content between two Drupal sites via JSON (Feeds extensible parser and JSON API Include modules), but I suppose it should work for other use cases as well.

As suggested in #3 above under 1, I could achieve multilingual import in two steps, by creating 2 different feed types (eg., feed_type_se (default language, sweedish), feed_type_en (the translated language)).

1. For feed_type_se (default language) I configure the feed type as follows:
- Language: Sweedish
- Insert new content items
- Update existing content items

When creating the feed, I provide the feed source in the default language, something like this:
https://sourcesite.se/se/jsonapi/node/article?jsonapi_include=1&filter%5Bfield_issue_reference.id%5D=a7d6789c-a2af-4ee7-819a-8206b9ce25e2
(I want to import a list of articles belonging to a journal issue, identified by the uuid a7d6789c-a2af-4ee7-819a-8206b9ce25e2)

2. For importing the translated content, I used this configuration while creating the feed type feed_type_en.
- Language: English
- Do not insert new content items (!)
- Update existing content items

Configure the map so that the translated items are mapped to the translated target fields, like source "title" is mapped to "title" in English, etc.

When creating the second feed, I provide the feed source in the translated language (here English), something like this:
https://sourcesite.se/en/jsonapi/node/article?jsonapi_include=1&filter%5Bfield_issue_reference.id%5D=a7d6789c-a2af-4ee7-819a-8206b9ce25e2

As for the unique field for the import to be mapped, I created a custom JSON ID field (field_json_id) on the target content type to be fed from the source. The source that will be imported into this field is the UUID as above (in JSON this appears as id of the source site item).

The tricky part is that this field_json_id, which is used as the unique field has to be marked as a translatable field (Users may translate this field) on the content type field setting. (Otherwise you get the "this title already exists" error message). And you should choose the translation language for the unique field as well, as in the image below.

Mapping the localized feed screen capture

ptmkenny’s picture

I tried to follow @marksmith's instructions, but my experience was a little different, so I'm going to write down what I did here.

I'm using the latest dev version of Feeds on Drupal 11.1.

I have a site with a default language of English and an additional language of Japanese.

I have a custom entity type Dinner with two translated fields, Apples and Oranges, and a third non-translated field, Broccoli.

First, I created a Feed Type "Dinner English". On the settings page, under "Processor" -> "Language", I selected English. Then, on the mappings, for the fields Apples and Oranges, which can be translated, I set the language to "English". Then I created a feed of this feed type and tested import; everything worked as expected.

Next, I created a Feed Type "Dinner Japanese". On the settings page, under "Processor" -> "Language", I selected Japanese. Then, on the mappings, for the fields Apples and Oranges, which can be translated, I set the language to "Japanese". Then I created a feed of this feed type and tested import; everything worked as expected.

Differences from what @marksmith reported:

  • I could use the same Feeds GUID for both the default language (English) and my other language (Japanese).
  • I used "Insert new content items" for both the default language and the other language.

I would be happy to make a docs page about this, but first I'd like to know why @marksmith and I needed different settings.

erwindeclerck’s picture

Issue summary: View changes

Hi everybody,

I think I found the reason for this strange error: #3126351: A translation already exists for the specified language
This is what I do: I import nodes from an old Drupal 7 site with 3 languages: default Enlish and Dutch and French as secondary and third language.
I use separate feeds to import each language..
In each feed I provide the langcode mapped from the language of the translation.
In each feed I provide the tranlation_id which I gave the same language as the language of the translation. (tranlation_id is the id that grouped the translations in the old Drupal 7 site.)
After importing the first language the node table gets a line extra for each imported node

nid vid type uuid langcode
2392 2419 event f7214d4e-e05c-418c-bba0-b0c5210a7756 en

Langcode is the default language of that node.
When I import the second language this langcode first is overwritten by the language in the mapping and you get: (fr in this case)

nid vid type uuid langcode
2392 2419 event f7214d4e-e05c-418c-bba0-b0c5210a7756 fr

Further up in the code the processor tries to create the second language but then discovers that fr already exists as the default language and stops with the message A translation already exists for the specified language

When I remove the langcode mapping in the second feed, the import works like charm!

Kind regards and thanks for this marvelous module.

Erwin