Internationalisation Django (on OSX)

两盒软妹~` 提交于 2019-12-18 10:23:10

问题


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 

回答1:


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

brew install gettext
brew link gettext --force



回答2:


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.




回答3:


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
    


来源:https://stackoverflow.com/questions/6860188/internationalisation-django-on-osx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!