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.
You will need:
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 template of 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.
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.
Add an example or an encoding error.
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 its time well spent.
Note this step is optional. 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.
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 -N 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. The -N option switches off fuzzy matching, so it will not apply any text matching algorithms when it migrates. Feel free to leave out the -N option, pomigrate2 will then perform fuzzy matching, some matches will be good and some will not be so good. You’ll need to review all these fuzzy matches.
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.