How to translate Magento using OmegaT software

I made a filter for OmegaT to import directly CSV. If you would like to try, the steps are shown here:

This article explains using OmegaT CAT (Computer Aided Translation) software to translate Magento into your language. Main benefit is re-using existing translations to improve consistency across all translated files.

Note: all steps below were tested on a Linux.


  • OmegaT software (download from
  • PO source files (explained below)
  • Translation memory made of existing translation (optional, explained below)


Create a directory for your translation project and two subdirectories, source/ and target/. Copy Magento en_US csv files to source/. The languages files can be found in app/locale/en_US/ directory of your Magento installation.


This software requires Java. Download version with JRE if you don’t have Java installed alread. Install it.

PO source files

OmegaT cannot work with CSV files directly. They need to be converted to PO files. You can use either Translate Tools - csv2po, but it requires working Python installation (note: the csv needs to have 3 columns, comment,source,target - just open file in spreadsheet editor and duplicate first column), or place the php script below in directory containing source/ and run it.

  1. <?php
  2. /*
  3. Tool to convert source language files to PO files
  4. */
  6. $src = 'source';
  8. $dir = scandir($src);
  9. for($i=0;$i<count($dir);$i++) {
  10.     if(is_file($src . '/' . $dir[$i])) {
  11.         $src_list = array();
  12.         $f_src = fopen($src . '/' . $dir[$i],"r");
  13.         while($r = fgetcsv($f_src,1000)) {
  14.             $src_list[(string)$r[0]] = $r[1];
  15.         }
  16.         fclose($f_src);
  17.         $f_out = fopen($src . '/' . $dir[$i] . '.po','w');
  18.         reset($src_list);
  19.         while(list($k,$v)=each($src_list)) {
  20.             $k = str_replace('"','"',$k);
  21.             $v = str_replace('"','"',$v);
  22.             $str = "#: $knmsgid "$k"nmsgstr "$v"nn";
  23.             fwrite($f_out,$str);
  24.         }
  25.         fclose($f_out);
  26.     }
  27. }

This will create a .po file corresponding to each .csv file. Those files contain string to be translated. Remove csv files from source/ directory.

Translation memory (optional)

As there are quite a lot of translations already started it is good to reuse existing translations. This means we have to prepare translation memory in TMX format out of already translated csv files. I couldn’t get po2tmx to work so i made a simple script. First concatenate all translated files into one file named all.csv, for example using the command cat *.csv > all.csv. Modify the script to have proper target language, then run it.

  1. <?php
  2. /*
  3. Tool to convert translated csv file to translation memory (TMX)
  4. */
  6. $dest_lang = 'PL';
  7. $src = 'all.csv';
  9. $src_list = array();
  10. $f_src = fopen($src,"r");
  11. while($r = fgetcsv($f_src,1000)) {
  12.     $src_list[(string)$r[0]] = $r[1];
  13. }
  14. fclose($f_src);
  15. $f_out = fopen('all.tmx','w');
  16. $str = <<<EOT
  17. <?xml version="1.0" encoding="UTF-8"?>
  18. <!DOCTYPE tmx SYSTEM "tmx11.dtd">
  19. <tmx version="1.1">
  20.   <header
  21.     creationtool="OmegaT"
  22.     creationtoolversion="1.7.3_1"
  23.     segtype="sentence"
  24.     o-tmf="OmegaT TMX"
  25.     adminlang="EN-US"
  26.     srclang="EN"
  27.     datatype="plaintext"
  28.   >
  29.   </header>
  30.   <body>
  31. EOT;
  33. fwrite($f_out,$str);
  34. reset($src_list);
  35. while(list($k,$v)=each($src_list)) {
  36.     $k = strip_tags($k);
  37.     $v = strip_tags($v);
  38.     $str = <<<EOT
  39.     <tu>
  40.       <tuv lang="EN">
  41.         <seg>$k</seg>
  42.       </tuv>
  43.       <tuv lang="$dest_lang">
  44.         <seg>$v</seg>
  45.       </tuv>
  46.     </tu>
  47. EOT;
  49.     fwrite($f_out,$str . "n");
  50. }
  51. $str = "</body>n</tmx>";
  52. fwrite($f_out,$str);
  53. fclose($f_out);

As a result you will get all.tmx file.

Create project

Run OmegaT application. Create a new project, input proper source, project and target directory, add source files (point to source/ directory). Set options: Options→Editing Behaviours to:

  • Source text: yes
  • Insert the best fuzzy match: yes
  • Allow translation to be equal to source: yes

Options→File Filters→PO Files→Edit to:

  • Set input and output encoding to UTF-8 for .po files (very important!)

Save project. Notice a new directory created when saving the project. Copy the all.tmx file to tm/ under project’s directory. Reload the project in OmegaT. If there are any errors reading the tmx file, note line number and fix the tmx file by hand (it is plain XML), errors may include tags or html entities. You can just remove the whole <tu> </tu> block. Reload until there are no translation memory errors. Now you can start translating.

Basic shortcuts are Ctrl+R to replace current segment with most matching translation memory item, Enter to accept current translation.

Back to Magento

When your translation is ready or you want to test it, use File→Create Translated Documents. This will cause translated PO files to appear in target/ directory. Info how to convert PO files back to csv will be added later...

Happy translating!

Questions: PM me piotrekkaminski

Convert the omegaT .PO files back to Magento readable .CSV

If you uploads the omegaT .PO files to your translation directory (for example. magento/app/local/da_DK) you can use this php script fired from within it.

foreach (glob("*.po") as $csv) file_put_contents(str_replace(".po", "", $csv), trim(preg_replace("/[rn]+/", "n", str_replace("[fuzzy] ", "", preg_replace('/(^|n)[^"][^n]*n/', "n", preg_replace(array("/s*nmsgid /", "/s*nmsgstr /"), array("n", ","), file_get_contents($csv)))))));