Django Internationalization, gettext and Mac OS X

The Django Internationalization translation machinery uses the standard gettext module that comes with Python (supposedly). When I tried to update the message file for our translation with the following command:

python manage.py makemessages -l nl

I received the following error:

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

Uh oh...it seemed that my Mac OS X (Snow Leopard) was missing gettext, a set of tools that provides a framework to help other GNU packages produce multi-lingual messages. Even though I have Xcode installed on my system, I was still missing the gettext program.

How to solve this problem?

First, I did a Spotlight search for gettext and found that there was a gettext program in /sw/bin/ that seemed to be part of Fink (an open source software collection and package manager I played with for a little while when I tried fixing other installation problems). That gettext did not seem to be working correctly however, so I continued my search online.

There was not a lot of information to be found on this problem through Google but one hint was to install a program called Poedit and add a reference to it to the PATH variable (add this line to your .bash_profile or .profile - depending on which one you use - PATH=$PATH:/Applications/Poedit.app/Contents/MacOS/ ).

Now, however I got another error message when trying to update the message file:

Error: errors happened while running msguniq
/bin/sh: msguniq: command not found os x

I was unable to find any useful information on that error message online so I decided to try and start over again. Because I did not trust the Poedit.app solution to gettext completely, I decided to take a look at the /sw/bin/ version of gettext. That lead me to take another look into Fink - a distribution of Unix Open Source software for Mac OS X and Darwin and a package manager. It brings a wide range of free command-line and graphical software developed for Linux and similar operating systems to your Mac.

After having updated my Fink configuration (sudo fink configure) and repaired it (my Fink installation somehow got damaged), I searched through the package list (fink list) and installed gettext and gettext-tools (sudo fink install gettext-tools).

After adding the path to the gettext directory /sw/bin/ to my PATH variable (add PATH=$PATH:/sw/bin/ to your .bash_profile or .profile) and trying to update the message file again: it worked!

I am going to try out using Fink more often for installing certain open source software and libraries.

  • Enjoyed this post? Please share it with others:
  • del.icio.us Favicon
  • Digg Favicon
  • Facebook Favicon
  • Google Favicon
  • LinkedIn Favicon
  • Reddit Favicon
  • Technorati Favicon
  • TwitThis Favicon
14 October 2009 • Django, Geek stuff, Information technology

Comments

Herri  on 01 Apr 2010 wrote:

Hi,

There are os x packages for gettext. No need to install fink nor compile the source. http://www.ellert.se/twain-sane/


Herson Leite  on 11 May 2011 wrote:

Hey,

I solved the problem with homebrew[1]:

$ brew install gettext

[1] - http://mxcl.github.com/homebrew/


herson leite  on 11 May 2011 wrote:

Sorry Bram, i forget one line:

$ brew install gettext
$ sudo brew link gettext

Will work fine!


Datnt  on 22 May 2011 wrote:

Thank you


Dana Woodman  on 16 Nov 2011 wrote:

@herson

Thanks! I had installed gettext with brew but didn’t do the whole `sudo brew link gettext`. That bit fixed my problem!

Cheers!


naia  on 26 Nov 2012 wrote:

Do you know how to remove gettext.so from my mac?

I can’t empty my Trash because it says: “The operation can’t be completed because the item “gettext.so” is in use.”

Currently in my Trash is MAMP.
Thank you!


Bram Braakman  on 26 Nov 2012 wrote:

Hi Naia,

Did you try rebooting and emptying the trash after that?

If that does not work you can Google for solutions on emptying the Trash (Mac OS X) with a ‘file being in use’.


Name:

Email:

Location:

URL:

Remember my personal information

Notify me of follow-up comments?

<< Back to main