pygettext.py and msgfmt.py on Mac OS X

Both of those scripts reside in the miscellaneous Tools directory of the Python source. This directory is often not included in a binary installation of Python such as the ones supplied by Apple in OS X. However, it is easy to download them separately from a Python source release; see the most recent releases here. For the current Python 2.7.3 release, you could do the following:

$ curl -O http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz
$ tar -xf Python-2.7.3.tgz 
$ cd Python-2.7.3
$ cd Tools/i18n/
$ ls
makelocalealias.py  msgfmt.py*          pygettext.py*

Beginning with Python 3.2, the Tools directory is installed by python.org OS X binary installers. You'll find it inside the Python framework at:

/Library/Frameworks/Python.framework/Versions/3.2/share/doc/python3.2/examples/Tools

With python 3 and MacOS >= 10.9, installing gettext via homebrew won't link the libraries and this will produce the error Can't find msgfmt.

This helps:

$ brew install gettext  # if not already done
$ brew link gettext --force

Thanks to https://stackoverflow.com/a/8785138/621690


create a symbolic link

sudo ln -s /Library/Frameworks/Python.framework/Versions/3.7/share/doc/python3.7/examples/Tools/i18n/pygettext.py /usr/local/bin/pygettext