Skip to Main Content
Import export

Importing Entries into a Multi Lingual Craft CMS Website

In this article I will demonstrate how to import entries into a Craft CMS multilingual site and have each entry associated with its corresponding alternate language entry.

Let's Get Started

I'm in the middle of migrating an old ExpressionEngine (EE) site, running 2.9.3, to Craft CMS. This site is also multilingual and uses the Transcribe addon for ExpressionEngine to power the multilingual aspect of the site.

Importing content is easy with Craft especially now that Feed Me was acquired by Craft and is a first party plugin.

As with any import set up your feed. In this case I chose XML because it's easy to write and simple to do in EE. You need a feed with English entries and one with French. I set up feeds at https:domain.com/en/export/news and https://domain.com/fr/export.com.

The first time I ran this I had English and French entries, but they were not associated with each other. The solution is actually quite simple.

In the multi-lingual channel you are importing to make sure to check the Propogate entries across all enabled sites. When you run the English feed. Entries will be added to both English and French side of the site.

Unique Identifier

Next in your import feeds you want to have a unique identifier. So that if the English entry and the French entry will have the same unique identifier.

Using EE and transcribe there is no clear way to output a unique identifier to the feeds. However I managed to do it by using an embed to pass in the current entries id and get the related entry id with another bit of code. Here is the Full XML feed -notice the embed on line 9.


    
      <root>
{exp:channel:entries channel="news" paginate="bottom" status="not foo" limit="500"}
  <entry>
    <count>{count}</count>
    <total_results>{total_results}</total_results>

    <unique>{entry_id}</unique>
    <opposite>
      {embed="export/rel-id" current_id="{entry_id}"}
    </opposite>

    <title><![CDATA[{title}]]></title>
    <url_title>{url_title}</url_title>
    <entry_id>{entry_id}</entry_id>
    <entry_date>{entry_date}</entry_date>
    <status>{if "{status}" =="open"}1{if:else}0{/if}</status> 
    <copy><![CDATA[{news_copy}]]></copy>
    {if news_offsite_link}
      <offsite_link>
        {news_offsite_link}
          <link><![CDATA[{link}]]></link>
          <link_text><![CDATA[{link_title}]]></link_text>
        {/news_offsite_link}        
      </offsite_link>
    {/if}
  </entry>
{/exp:channel:entries}
</root>
    
  

And now the embedded template. Which uses the language switch code to get the related entry id.

    
      {exp:transcribe:language_links has_entry="yes" entry_id="{embed:current_id}"}
  {languages}{rel:entry_id}{/languages}
{/exp:transcribe:language_links}
    
  

Feed Me Settings

First set up your channel and fields to import. Don't forget to add a unique identifier field so that you can get your entries associated with each other. This field can be removed once the import is complete.

Next create an English feed with the following settings and then copy the feed but change the Target Site setting to French from English.



Next be sure to set your Import Strategy to Create new elements and Update existing elements. This is necessary to have the second import overwrite the entries in French side with French content.

Save and continue. Set the primary element and go to the final page. Here you can set the elements to import to the correct fields you've created in Feed Me. You may need to experiment a bit to get things to work as expected. Usually however it is simply a matter of mapping the xml elements to the fields and you're done.

Be sure to map your unique identifier. I don't know why but I called my xml field <opposite>1234</opposite>. You'll be better off calling it <unique_identifier>1234</unique_identifier>

Run Your Feeds

Run your feeds, check the feed me logs. Everything should have run smoothly. Assuming it has go look at your entries and you'll see both English and French entries associated with each other correctly.