49

I'm trying to internationalize a Django app by following the wonderful Django documentation. The problem is when I try to run command to create language files:

python manage.py makemessages -l fr

It outputs an error :

CommandError: Can't find msguniq. Make sure you have GNU gettext tools 0.15 or newer installed.

My configuration :

  • OS : OSX El Capitan v10.11.3
  • Python : v3.5
  • Django : v1.8
Louis Barranqueiro
  • 10,058
  • 6
  • 42
  • 52

4 Answers4

55

Install gettext GNU tools with Homebrew using Terminal

  1. Install Homebrew : /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  2. Install GNU gettext : brew install gettext
  3. Create symlink : brew link gettext --force
Louis Barranqueiro
  • 10,058
  • 6
  • 42
  • 52
  • I get the error: Linking /usr/local/Cellar/gettext/0.19.7... Error: Could not symlink share/info/autosprintf.info /usr/local/share/info is not writable. – samir105 May 06 '16 at 09:54
  • Did you try with sudo? – Louis Barranqueiro May 06 '16 at 09:55
  • With sudo I get the following: Error: Cowardly refusing to 'sudo brew link' You can use brew with sudo, but only if the brew executable is owned by root. However, this is both not recommended and completely unsupported so do so at your own risk – samir105 May 06 '16 at 10:00
  • Should I uninstall gettext and reinstall with sudo? – samir105 May 06 '16 at 10:01
  • Do you have the same configuration ? – Louis Barranqueiro May 06 '16 at 10:02
  • My configuration: OS : OSX El Capitan 10.11.4 Python: 2.7.10 Django: 1.9.5 – samir105 May 06 '16 at 10:12
  • Thanks for your response. Setting path worked for me as suggested in this answer: http://stackoverflow.com/a/35579852/38856 – samir105 May 06 '16 at 10:22
  • 1
    good news :) Read this : http://stackoverflow.com/questions/26647412/homebrew-could-not-symlink-usr-local-bin-is-not-writable and try `brew doctor` to check if everything is fine. – Louis Barranqueiro May 06 '16 at 10:27
  • Thanks a lot. `brew doctor` gave me a hint to do chown on some directory, after doing it `brew link gettext --force --overwrite` worked! – samir105 May 07 '16 at 15:29
17

For Windows:

  1. Download gettext and install

  2. Add in system var PATH: C:\Program Files\gettext-iconv\bin (if you didn't it during installation)

  3. Check or create in your project directory locale/

  4. Check or add in settings.py: LOCALE_PATHS = (BASE_DIR + 'locale/', )

Enjoy by django-admin makemessages -l fr. If still repeating don't forget to restart your shell to update env vars

  • 5
    Please run the command in winodws CMD (press windows+r and then type "cmd") . In vs code terminal is not working. – MilanBogic Jun 23 '21 at 18:55
  • Download gettext and `install`. How to install it? There is no install file for windows in it – oruchkin Dec 15 '22 at 15:12
14

First make dir in root project folder with name locale then run

sudo apt install gettext
Bambier
  • 586
  • 10
  • 16
7

If you try running link gettext --force it warns you:

Note that doing so can interfere with building software.

The safest way to use it is to add gettext binary to your path:

export PATH="/usr/local/opt/gettext/bin:$PATH"
Vlad T.
  • 2,568
  • 3
  • 26
  • 40
  • 1
    I have it in .bashrc but .bash_profile also will work, see https://apple.stackexchange.com/a/51038/83258 – Vlad T. Apr 12 '18 at 12:51