Please note: This site uses CSS3. Your browser does not sufficiently support this standard. Please upgrade your browser. It's free.

Installing gettext on Snow Leopard

November 16, 2010

Yesterday I started working on internationalization of one of our Django projects.

After I marked all translatable strings in the test pages, I tried to ran the command to generate the language files django-admin makemessages -l nl and I got an error message saying:

Error: errors happened while running xgettext on __init__.py
/bin/sh: xgettext: command not found

I am running Snow Leopard and have the Xcode tools installed. I searched for the error on Google and I found a blog post by Bram Braakman, who had the same problem. It turned out I didn't have gettext on my pc.

Brams post lists a solution, but it involves working with Fink. I personally don't like to use Fink or its rival Darwin Ports and I prefer to compile software directly on my MAC.

I downloaded gettext and decided to try to compile gettext on OS X myself. Looking at the number of listed depencies I expected it to be a cumbersome process, but much to my surprise. It was as easy as one, two, three. This is what I did:

Download the gettext source code from their website. Open Terminal.app (it's in the /Applications/Utilities folder) and change to the directory you've downloaded gettext to. For this article I assumed you've used the default Downloads folder.

cd ~/Downloads/

Now unpack the source code and go the the source code directory.

tar xzvf gettext-0.18.1.1.tar.gz
cd gettext-0.18.1.1

The rest is easy. It's the standard procedure when installing packages from source code. It only involves a little wait after every command.

./configure
make
sudo make install

That was all. No problems with depencies. Seems all of them are already preinstalled. Installing gettext on OS X is easy, but make sure you have Xcode installed before you start with this. Good luck.