Django 国际化(在 OSX 上)
我在我的OSX Leopard上尝试让gettext在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
在终端中我遇到了同样的错误,除非我把这个放在我的bash配置文件里:
PATH=$PATH:/Applications/Poedit.app/Contents/MacOS/
但是这样我又遇到了这个错误:
Error: errors happened while running msguniq
/bin/sh: msguniq: command not found os x
3 个回答
7
强行使用 brew link
可能会带来不好的后果。与其强行链接,不如修改虚拟环境的路径(PATH)。所以,
首先,安装 GNU gettext:
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
10
我觉得你需要安装gettext。Poedit只包含了gettext包中的一些程序。
安装gettext(不仅仅是gettext)最简单的方法可能是通过homebrew。一旦你安装了homebrew,就可以运行 brew install gettext
来安装它。之后,确保 /usr/local/Cellar/gettext/0.18.1.1/bin
里的程序在你的 $PATH
中。
需要注意的是,homebrew需要你安装Xcode,因为它通常是从源代码安装软件包的(你可以从Mac App Store免费获取Lion版本的Xcode)。
补充一下:我之前没注意到你不是用Lion。如果你用的是Snow Leopard,可以在App Store上花5美元下载Xcode。至于Leopard,我想Xcode在安装光盘上。
100
安装完成后,试着链接一下gettext。这对我解决了问题。
brew install gettext
brew link gettext --force