Easiest way to generate localization files

Use scripts. Assume your source code is in the directory $SRC, so create directory $SRC/po for i18n files (pot, po, mo etc). Then create file $SRC/po/POTFILES.in where specify path to source code files with gettext function calls. It may look like:

[encoding: UTF-8]
./main.cpp
./plugins/list.cpp

Now you can use the following commands (inside directory $SRC):

For updating master-file messages.pot:

intltool-update --pot --gettext-package=messages --verbose

For merging changes from messages.pot to fr.po file, for example:

msgmerge -U fr.po messages.pot

To generate mo file use command:

msgmerge -o - fr.po messages.pot | msgfmt -c -o fr/LC_MESSAGES/programname.mo -

Of course directory fr/LC_MESSAGES/ must be created before that call, you can also delete existing fr/LC_MESSAGES/programname.mo before execution

In order to speed up process place all such commands into the corresponding .sh-files for example.


You can use Transifex, used by quite a few Python projects (Django, Mercurial). It has a web-based editor and command-line client for automation and also supports .NET, if that can be of help.

Disclaimer: I'm the Transifex project lead.


It eludes me how you want to achieve a real translation without editing the .po files for each language? Magic?

Edit (after comment) - how to automate the generation of the .po files:

I don't use Gettext, but from the wiki page it looks like you only have to call

msginit --locale=xx --input=name.pot

for every language you want to support. I would generate a script that generates all the language files, give them to the translators, and when you get them back run msgfmt on them.


I've just done this for a project I'm working on, for us the process is like this:

First, I have a POTFILES.in file which contains a list of source files needing translation. We actually have two files (e.g. admin.in and user.in), as the admin interface doesn't always need translating. So we can send translators only the file containing strings the users see.

Running the following command will create a .pot template from the POTFILES.in:

xgettext --files-from=POTFILES.in --directory=.. --output=messages.pot

Run the above command from the po/ directory, which should be a subdirectory of your project and contain the POTFILES.in file. The .pot file has the exact same format as a .po file, but it is a template containing no translations. You create a new template whenever new translatable strings have been added to your source files.

To update the already translated .po files and add new strings to them, run:

msgmerge --update --no-fuzzy-matching --backup=off da.po messages.pot

In the above example I disable fuzzy matching, as our strings are a mess and it did more harm than good. I also disabled backup files, as everything is in subversion here. Run the above command for each language, in this case I updated the danish translation.

Finally run msgfmt to create the .mo files from the .po files:

msgfmt nl.po --output-file nl.mo

Ofcourse, you wouldn't want to run this manually everytime, so create some scripts (or preferably one or more Makefiles) to do this for you.

Note that your directory layout is slightly different from my situation, so you will have to adjust output filenames/paths a bit, but the steps should be the same.