Python 国际化Django(在OSX上)
我正试图让gettext在我的OSX Leopard上的Django工作Python 国际化Django(在OSX上),python,django,unix,internationalization,gettext,Python,Django,Unix,Internationalization,Gettext,我正试图让gettext在我的OSX Leopard上的Django工作 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 在Terminal中,我得
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
在Terminal中,我得到了相同的错误,除非我将其放在我的bash配置文件中:
PATH=$PATH:/Applications/Poedit.app/Contents/MacOS/
但是我得到了这个错误:
Error: errors happened while running msguniq
/bin/sh: msguniq: command not found os x
我认为您需要安装gettext。Poedit只包括gettext包提供的一些程序 安装(不仅仅是)gettext最简单的方法可能是通过。安装了自制软件后,运行
brew install gettext
。之后,请确保/usr/local/ceral/gettext/0.18.1.1/bin
中的程序位于$PATH
上
请注意,您需要安装Xcode以便homebrew正常工作,因为它通常从源代码安装软件包(您可以从Mac App Store免费获得Xcode for Lion)
编辑:我忽略了你不使用Lion。对于雪豹,你可以从应用商店以5美元的价格获得XCode。我认为Leopard的XCode在安装盘上。安装后,请尝试链接gettext。这为我解决了问题
brew install gettext
brew link gettext --force
强制执行
brew链接
可能会导致负面后果。最好修改虚拟环境的路径,而不是强制链接。所以
brew install gettext
# 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
该命令还解决了我的下一个问题:错误:运行msguniq/bin/sh:msguniq:command not found时出错我的主要问题是没有运行
brew链接--force gettext
命令。一旦我运行它,一切都像一个魅力。非常感谢。请您简单解释一下为什么Mac OS需要命令brew链接--force gettext
?FWIW在我的情况下,第1行(安装)说我已经安装了gettext。所以我运行了第二行(链接),之后一切都正常了。谢谢多米尼克和塞萨尔·卡纳萨!同样可以使用(另一个包管理器):安装rudix,然后sudorudix-igettext
。顺便说一句,rudix本身可以安装在。