5

I've already imported a data set of about 1500 articles, all in English. I have another set of the data with matching node ids but in different languages. Can I import a second file into Drupal 7 and have the localized content mesh up with the existing data?

Currently when I try to import the data it overwrites the existing content, I need them to co-exist with the only difference being a language code.

5
+50

Import from two xml files (on for each language), my empiric solution :

  1. I created two feed imports.
  2. I forced the language field for each one.
  3. Two separated nodes were created for each content (one in each language) but it didn't links the translations.
  4. So I used a SQL query to finish the job, it's based on the feeds uuid

Note: In order for this to work your GUID must match between the two sources. If you have set that to the node title it is important that you turn off the option to replace content as it will update the previous import :/

UPDATE
    node n,
    feeds_item lng1,
    feeds_item lng2
SET
    n.tnid = lng1.entity_id
WHERE
    (
        n.nid = lng1.entity_id
        OR
        n.nid = lng2.entity_id
    )
    AND lng1.id='feeds_importname_for_lng1'
    AND lng2.guid=lng1.guid
    AND lng2.id='feeds_importname_for_lng2'
  • Hmm... I really like your approach but actually I found the GUID matching doesn't work. When I create two separate imports and set say the title to the same GUID it replaces the other one b/c that's what I had it to setup to do.... Actually even if I turn that off it assumes that my GUID (title) is the same name in both languages :/ – shaneonabike Jan 28 '15 at 18:34
  • I worked it out finally and have modified the tip to help out – shaneonabike May 1 '15 at 1:27
0

It is possible to achieve this with needing SQL queries.

Also if you want to do anything with field translation in feeds, make sure you have a current version. Newer than a year ago, because of https://www.drupal.org/node/1183440 This version supports entity translation, which you'll need of course. It allows for fields to be translated. So you'll have 1 entity which several fields. These fields can be translated independently.

You will have to set a Unique identifier setting on both feeds importers to be imported and these should of course be the same (ypur matching node ids). You can then set in the processors' mapping settings that an input record should a into a particular fields' translation.

So,

  1. create two importers, one for each language.
  2. in both, set your 'matching node ids' as 'Used as Unique' In the feeds processor mapping settings.
  3. set the language setting in the mapping.

If you can see the language setting, doublecheck the Entity Translations and field settings.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.