31

I'm trying to get gettext to work in Django on my OSX Leopard

django_manage.py makemessages -l nl
Importing Django settings module settings
processing language nl
Error: errors happened while running xgettext on __init__.py
/bin/sh: xgettext: command not found

In Terminal I get the same error, unless I put this in my bash profile:

PATH=$PATH:/Applications/Poedit.app/Contents/MacOS/

But then I get this error:

Error: errors happened while running msguniq
/bin/sh: msguniq: command not found os x 
Cluesane
  • 311
  • 1
  • 3
  • 3

3 Answers3

100

After installing, try linking gettext. This solved the problem for me.

brew install gettext
brew link gettext --force
Cesar Canassa
  • 18,659
  • 11
  • 66
  • 69
dominik
  • 5,745
  • 6
  • 34
  • 45
  • That command also solved my next issue : Error: errors happened while running msguniq /bin/sh: msguniq: command not found – vinyll Jul 17 '12 at 09:34
  • 1
    My main problem was that I didn't run the `brew link --force gettext` command. Once I ran it, everything worked like a charm. Thank you! – aka_le_Mulder Jul 26 '13 at 06:33
  • 1
    Could you please add some simple explanation to why the command `brew link --force gettext` is required for Mac OS? – Alston Jul 26 '16 at 13:42
  • FWIW in my case, the 1st line (install) said I already had gettext installed. So I ran the 2nd line (link) and everything worked after that. Thanks dominik and @Cesar Canassa! – Eric Dec 13 '16 at 12:59
10

I think you need to install gettext. Poedit includes only some of the programs provided by the gettext package.

Probably the easiest way to install (not only) gettext is via homebrew. Once you have homebrew installed, run brew install gettext. After that, make sure that the programs in /usr/local/Cellar/gettext/0.18.1.1/bin are on your $PATH.

Note that you need to have Xcode installed for homebrew to work as it usually installs packages from source (you can get Xcode for Lion for free from the Mac App Store).

Edit: I overlooked that you don't use Lion. For Snow Leopard, you can get XCode from the App Store for $5. XCode For Leopard is I think on the installation disk.

Jakub Roztocil
  • 15,930
  • 5
  • 50
  • 52
  • And the same could be done with [rudix](http://rudix.org/) (yet another package manager): install rudix, then `sudo rudix -i gettext`. BTW, rudix itself could be installed in [virtualenvwrapper](http://virtualenvwrapper.readthedocs.org/en/latest/index.html). – iutinvg Oct 04 '12 at 03:17
7

Forcing brew link may result in negative consequences. It's better to modify virtual environment's PATH instead of force-linking. So,

  1. Install GNU gettext:

    brew install gettext
    
  2. Add it to your virtual environment:

    # Get this from the brew's "Summary"
    GETTEXT_PATH="/usr/local/Cellar/gettext/0.19.8.1/bin" 
    
    # Change "postactivate" to "activate" if you're using python3's venv
    FILE="YOUR_VENV/bin/postactivate"   
    
    echo "" >> $FILE
    echo "export PATH=\$PATH:$GETTEXT_PATH" >> $FILE
    
Max Malysh
  • 29,384
  • 19
  • 111
  • 115