This page will describe how you can help internationalize Mercurial by translating it into your language of choice. Mercurial uses the standard i18n [http://www.gnu.org/software/gettext/ Gettext] infrastructure, and we will only give a quick introduction to it here. Please take a look at the Gettext manual if you are unfamiliar with translating software.

Starting a New Translation

If you find that Mercurial is not yet translated into your favorite language, then you can start one. First contact the development MailingList to see if an effort is already underway.

Translations are stored as xx.po and xx_yy.po files in the i18n/ directory. The xx corresponds to the language code of the translation and the yy is the optional country code. Find your language code in the [http://www.gnu.org/software/gettext/manual/html_node/Usual-Language-Codes.html ISO 639-1 list] and, if needed, your country code in [http://www.gnu.org/software/gettext/manual/html_node/Country-Codes.html ISO 3166 list].

To create a new translation you first create a i18n/hg.pot file. This is can be done with the Makefile:

% make update-pot

The Makefile requires the pygettext and msgcat programs. If you do not have pygettext installed you can find it [http://svn.python.org/view/python/trunk/Tools/i18n/ on the Python SVN server].

You create your translation from the hg.pot file. You can use the msginit program to start a new translation or you can copy the hg.pot file to the correct xx.po name.

Now edit the xx.po file with your favorite PO editor, such as [http://www.poedit.net/ Poedit] or Emacs. You can also simply edit the xx.po file with a text editor (such as WordPad), but you must then be careful to keep the formatting.

To actually use the translation you need to compile the xx.po file into a xx.mo If you have the msgfmt program installed you can do the compilation like this:

% python setup.py build_mo

Alternatively, you can let Poedit do the compilation or you can use the msgfmt.py script found alongside the pygettext.py script. The resulting file should be called hg.mo and must be saved as

locale/xx/LC_MESSAGES/hg.mo

Using setup.py does this for you, if you compiled the xx.po file manually you have to create the directory structure yourself.

Now ensure that your LANGUAGE environment variable is set to 'xx'. In a shell from the Bash-family you do this by:

% export LANGUAGE=xx

Then run hg to see if your translations are picked up.

Updating a Translation

When changes are made to the Mercurial source, new strings will appear that must be translated. Updating an old translation to take these strings into account is easy: regenerate the hg.pot file as above and use the msgmerge program to merge new strings into the translation:

msgmerge -U i18n/xx.po i18n/hg.pot

Then translate the new strings, make the xx.mo file and enjoy.