<p>You could manage all your translations in one csv file. There's <a href="https://craftcms.stackexchange.com/q/205/125">another Q/A</a> about translation files, where <a href="https://craftcms.stackexchange.com/users/54/">@Bill Criswell</a> explains how you can use csv files for translations. I added some variables to his script to make it well adaptable to multiple locales.</p>

<p>Set up your new csv file with a column for each locale. Then add the script to each of your <code>lang.php</code> files and configure <code>$this_locale_column</code> according to the file's locale.</p>

<pre class="lang-php prettyprint-override"><code>&lt;?php

$path = $_SERVER['DOCUMENT_ROOT'].'/../craft/translations/translations.csv';
$delimiter = ';';
$skip_rows = 1; //skip header rows
$primary_locale_column = 0; //set primary locale column
$this_locale_column = 1; //set secondary locale column for this `lang.php` file

$translations = array();
$translations_file = fopen($path, 'r');

if ($translations_file) {
    while(($translation = fgetcsv($translations_file, 1024, $delimiter)) !== FALSE) {
        if($skip_rows != 0) { $skip_rows--; continue; }
        $translations[$translation[$primary_locale_column]] = $translation[$this_locale_column];
    }
}

return $translations;
</code></pre>

CC BY-SA 3.0
2014-08-06T18:20:31.480Z
2014-08-06T18:20:31.480Z
2017-04-13T12:51:00.200Z
carlcs
<p>I've set up multiple <a href="http://buildwithcraft.com/help/static-translations" rel="nofollow">translation files</a> (<code>de.php</code>, <code>fr.php</code>, <code>es.php</code> etc.) in <code>craft/translations/</code> to translate static text.</p>

<p>While my site is in development, I am trying to keep these <code>lang.php</code> files in sync, so that they all contain at least the strings of the primary locale as array keys.</p>

<p>But the more strings are added or changed, the more annoying this undertaking gets. Any idea on how I could make this more simple and efficient?</p>

<localization>
Keep translation files in sync?
# Keep translation files in sync?

(Asked by: username_0 on 2014-08-06)

I've set up multiple [translation files](http://buildwithcraft.com/help/static-translations) (`de.php`, `fr.php`, `es.php` etc.) in `craft/translations/` to translate static text.

While my site is in development, I am trying to keep these `lang.php` files in sync, so that they all contain at least the strings of the primary locale as array keys.

But the more strings are added or changed, the more annoying this undertaking gets. Any idea on how I could make this more simple and efficient?

**Tags:** localization


---

## 1 answers

### Answer by username_0 on 2014-08-06. Score: 4 | Accepted answer

You could manage all your translations in one csv file. There's another Q/A about translation files, where @Bill Criswell explains how you can use csv files for translations. I added some variables to his script to make it well adaptable to multiple locales.
Set up your new csv file with a column for each locale. Then add the script to each of your lang.php files and configure $this_locale_column according to the file's locale.


---

