Translate Toolkit & Pootle

Tools to help you make your software local

User Tools


Migrating your translations

You very often need to migrate older translations to newer template or POT files. There are a number of Gettext tools that can manage this but they do not handle the situation where files have been renamed and moved. The pomigrate2 script allows us to migrate between versions where there has been considerable change.

This migration HOWTO takes you through the steps in a generic fashion so that you can apply it to any of your projects. We use OpenOffice.org as an example for clarity. Our task in the examples is to migrate old translation for OpenOffice.org 1.1.3 to OpenOffice.org 2.0.

Requirements

You will need:

Preparing the new POT files

We need the new POT files. Either download these from the project or generate them using moz2po, oo2po or the other tools of the Translate Toolkit. The POT files are templates for the destination files that we will be creating.

oo2po -P en-US.sdf ooo-20-pot

This will create new POT files in ooo-20-pot.

Checking your old PO files for errors

We will be migrating your old PO files into the new POT files. This is a good opportunity to check for encoding errors and inconsistencies.

We use pocompendium to check for encoding errors:

pocompendium check.po -d ooo-113-old

This will create a compendium PO files, check.po, from all the PO files in the directory ooo-113-old, where ooo-113-old contains all your old translations. pocompendium is a wrapper around various Gettext tools, encoding errors will appear as errors from those tools.

Use your text editor to find and correct these errors. If you do not correct these now they will migrate to your new version. Once encoding errors are fixed they're usually gone for good, so it is time well spent.

Optional: Checking your old PO files for consistency

Note this step is optional, a more detailed explanation is given in checking for inconsistencies. We now look at consistency within the translations. The first check extracts situations were the same English string was translated in two different ways:

pocompendium --ignore-case --accel-amp --errors check.po -d ooo-113-old

In check.po you will find all situations where the same English text was translated differently. We use --accel-amp to remove accelerator markers (you'll change this depending on the one used by the project - we can do & _ or ~). Now view check.po in a PO editor or text editor. You will need to correct each inconsistency in the source PO files, using check.po as the guide. Many of the errors are usually spelling mistakes. You can regenerate check.po from time to time until all inconsistencies are justified or removed.

Then we check for words in your language that are used for more than one English concept. You don't for instance want the same word for Cancel and Delete. For this we invert the compendium.

pocompendium --invert --ignore-case --accel-amp --errors check.po -d ooo-113-old

We now have a file similar to the previous one except your language appears in the msgid and the English appears in the msgstr. Look for inconsistencies that would cause problems for the user and correct them in the source files.

Migrate

You are now ready to migrate using pomigrate2. You have created your destination POT files and all your PO files are clean and ready to migrate.

pomigrate2 ooo-113-old ooo-20-new ooo-20-pot

This will take all translations from ooo-113-old and migrate them to ooo-20-new using ooo-20-pot as templates. By default pomigrate2 migrates without any fancy text matching, there are options to allow for fuzzy matching and the use of a compendium. Read the pomigrate2 help page to find out more about these options.

Techie: what does pomigrate2 do to your file?

This section is for those insanely curious about what pomigrate will do to their files. You don't need to understand this section

  • Init stage
    • If a file has not changed location between old and new then it is simply copied across
    • If it has moved then we try to find a file by the same name and move ours there. If there are multiple files by the same name, then we join them together and copy them
    • If a file does not exist then we initialise it
  • Update stage
    • We now update our translations using msgmerge or pot2po
    • If you asked for a compendium, we will build one from the existing files and update using it and optionally other external compendiums

That's it. At the end you should have every file that needs translation updated to the latest template files. Files that moved should still be preserved and not lost. Files that where renamed will still be translated if you used a compendium otherwise they will be untranslated.

How well did you do

Congratulations! Your files are now migrated.

You might want to see how much of your old work was reusable in the new version:

pocount ooo-20-new

This will use pocount to count the words in your new files and you can compare the number of translate and untranslated messages from your old version.

Conclusion

Your files have now been migrated and are ready for updating. If files have been moved or renamed, and you used a compendium, then most likely you have most of that work translated.
{"cc_re__cc_re__cc_by_sa_3_0": ["></li><li><div class=\"li\"><a href=\"/wiki/ru/toolkit/migrating_translations\" class=\"wikilink2\" title=\"\u0420\u0443\u0441\u0441\u043a\u0438\u0439\">ru</a></div></li></ul>&nbsp<sup><a href=\"/wiki/wiki/translation/about\" class=\"wikilink1\" title=\"wiki:translation:about\">?</a></sup></div>       </li>\n   </ul>\n<div class=\"clearer\"></div>\n\n    </div>\n\n    <div id=\"dokuwiki__footer\">\n      \n<div class=\"doc\">\n  toolkit/migrating_translations.txt &middot; Last modified: 2012/10/30 12:49 by dwaynebailey &middot;\n  <div class=\"license\"><a href=\"http://creativecommons.org/licenses/by-sa/3.0/\" rel=\"license\"><img src=\"/wiki/lib/images/license/button/cc-by-sa.png\" class=\"medialeft licbutton\" alt=\"CC Attribution-Share Alike 3.0 Unported\" /></a> </div></div>\n\n    </div>\n\n\n  </div></div><!-- /site -->\n\n  <div class=\"no\"><img src=\"/wiki/lib/exe/indexer.php?id=toolkit%3Amigrating_translations&amp;1487646845\" width=\"2\" height=\"1\" alt=\"\" /></div>\n  <!--[if ( IE 6 | IE 7 | IE 8 ) ]></div><![endif]-->\n</body>\n</html>\n"]}