<p>We recently built our first multi lingual site on craft and used FeedMe to import our entries. What we did was to set up fields such as enDesc, deDesc, svDesc. Then when we imported our entries into craft mapping all of our multi lingual content to be spread across these fields in a single locale. Once this was done we then ran a script across the database to copy the content from deDesc into enDesc on the entry with the locale set to de, and then the same for sv also. Here is the script we built to get this job done. We ran this script from a program called CodeRunner on Mac, but you could equally FTP this up to the server and navigate your browser to it to run the script.</p>

<pre><code>&lt;?php
$servername = "XX.XXX.XXX.XXX";
$username = "db_username";
$password = "db_password";
$dbname = "db_name";
date_default_timezone_set('GMT');

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn-&gt;connect_error) {
    die("Connection failed: " . $conn-&gt;connect_error);
}
echo "Connected successfully";
$fieldName = "Desc";
$failed = 0;
$result = $conn-&gt;query("SELECT * FROM craft_content WHERE field_de".$fieldName." &lt;&gt; '' AND locale = 'en';");
while($row = $result-&gt;fetch_assoc()) {
    $elementId = $row['elementId'];
    $desc = $row['field_de'.$fieldName];
    if ($conn-&gt;query("UPDATE craft_content SET field_en".$fieldName."='".$desc."', field_de".$fieldName."=NULL WHERE elementId='".$elementId."' AND locale = 'de';") === TRUE) {
        echo "Updated ".$row['title']." - de";
    } else {
        echo "Failed ".$row['title']." - de";
        $failed++;
    }
}
$result = $conn-&gt;query("SELECT * FROM craft_content WHERE field_swe".$fieldName." &lt;&gt; '' AND locale = 'en';");
while($row = $result-&gt;fetch_assoc()) {
    $elementId = $row['elementId'];
    $desc = $row['field_swe'.$fieldName];
    if ($conn-&gt;query("UPDATE craft_content SET field_en".$fieldName."='".$desc."', field_swe".$fieldName."=NULL WHERE elementId='".$elementId."' AND locale = 'sv';") === TRUE) {
        echo "Updated ".$row['title']." - swe";
    } else {
        echo "Failed ".$row['title']." - swe";
        $failed++;
    }
}
if ($failed == 0) {
    if ($conn-&gt;query("UPDATE craft_content SET field_de".$fieldName."=NULL, field_swe".$fieldName."=NULL;") === TRUE) {
        echo "Cleanup Complete";
    } else {
        echo "Cleanup Failed";
    }
}
?&gt;
</code></pre>

<p>Once this had completed, the values from deDesc and svDesc should have copied into enDesc on both the German and Swedish locale entries. The values for deDesc and svDesc will also be removed if there were no errors. All you need to do now is rename your field from enDesc to desc and delete the deDesc and svDesc fields from craft. Rinse and repeat this process for each field and cleanup the fields afterwards and that should sort out your multilingual import for you.</p>

<p>Just make sure to take database backups frequently in case there are any errors though.</p>

CC BY-SA 3.0
2016-12-13T08:39:45.977Z
Thx a lot for sharing your solution. This come very handy when importing multilingual content. I my case we have to import all entries in two different languages several time a month when any data has been updated by the client.
jgrote
CC BY-SA 3.0
2016-12-14T09:15:23.357Z
You're welcome. I'm glad it helped you reach a solution for your setup. We are in a similar situation with new content still being added to the old site until launch. This could be handled by setting up a CRON to run our import which could target an RSS feed on the old site, but we are just manually importing currently as our content structure has now changed a little. The joys of migrating content!
Matt Shearing
CC BY-SA 3.0
2016-12-12T14:59:10.273Z
2016-12-12T14:59:10.273Z
Matt Shearing
<p>I am currently using <a href="https://straightupcraft.com/craft-plugins/import" rel="nofollow noreferrer">an import plugin</a> to import csv data into a channel section and it works just fine. Now I want to import the entries in a second language. Does anyone have any experiences with this?
Since the import works great, I could set up a new channel for the second language, but I wonder if there's a chance to import translations for existing entries.</p>

<import><language>
Multilinugual Import
# Multilinugual Import

(Asked by: username_0 on 2016-12-12)

I am currently using [an import plugin](https://straightupcraft.com/craft-plugins/import) to import csv data into a channel section and it works just fine. Now I want to import the entries in a second language. Does anyone have any experiences with this?
Since the import works great, I could set up a new channel for the second language, but I wonder if there's a chance to import translations for existing entries.

**Tags:** import, language


---

## 1 answers

### Answer by username_1 on 2016-12-12. Score: 3 | Accepted answer

We recently built our first multi lingual site on craft and used FeedMe to import our entries. What we did was to set up fields such as enDesc, deDesc, svDesc. Then when we imported our entries into craft mapping all of our multi lingual content to be spread across these fields in a single locale. Once this was done we then ran a script across the database to copy the content from deDesc into enDesc on the entry with the locale set to de, and then the same for sv also. Here is the script we built to get this job done. We ran this script from a program called CodeRunner on Mac, but you could equally FTP this up to the server and navigate your browser to it to run the script.
connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
$fieldName = "Desc";
$failed = 0;
$result = $conn->query("SELECT * FROM craft_content WHERE field_de".$fieldName." <> '' AND locale = 'en';");
while($row = $result->fetch_assoc()) {
    $elementId = $row['elementId'];
    $desc = $row['field_de'.$fieldName];
    if ($conn->query("UPDATE craft_content SET field_en".$fieldName."='".$desc."', field_de".$fieldName."=NULL WHERE elementId='".$elementId."' AND locale = 'de';") === TRUE) {
        echo "Updated ".$row['title']." - de";
    } else {
        echo "Failed ".$row['title']." - de";
        $failed++;
    }
}
$result = $conn->query("SELECT * FROM craft_content WHERE field_swe".$fieldName." <> '' AND locale = 'en';");
while($row = $result->fetch_assoc()) {
    $elementId = $row['elementId'];
    $desc = $row['field_swe'.$fieldName];
    if ($conn->query("UPDATE craft_content SET field_en".$fieldName."='".$desc."', field_swe".$fieldName."=NULL WHERE elementId='".$elementId."' AND locale = 'sv';") === TRUE) {
        echo "Updated ".$row['title']." - swe";
    } else {
        echo "Failed ".$row['title']." - swe";
        $failed++;
    }
}
if ($failed == 0) {
    if ($conn->query("UPDATE craft_content SET field_de".$fieldName."=NULL, field_swe".$fieldName."=NULL;") === TRUE) {
        echo "Cleanup Complete";
    } else {
        echo "Cleanup Failed";
    }
}
?>

Once this had completed, the values from deDesc and svDesc should have copied into enDesc on both the German and Swedish locale entries. The values for deDesc and svDesc will also be removed if there were no errors. All you need to do now is rename your field from enDesc to desc and delete the deDesc and svDesc fields from craft. Rinse and repeat this process for each field and cleanup the fields afterwards and that should sort out your multilingual import for you.
Just make sure to take database backups frequently in case there are any errors though.

> **Comments:**
> **username_0**: Thx a lot for sharing your solution. This come very handy when importing multilingual content. I my case we have to import all entries in two different languages several time a month when any data has been updated by the client.  
> **username_1**: You're welcome. I'm glad it helped you reach a solution for your setup. We are in a similar situation with new content still being added to the old site until launch. This could be handled by setting up a CRON to run our import which could target an RSS feed on the old site, but we are just manually importing currently as our content structure has now changed a little. The joys of migrating content!  

---

