国际化Django(在OSX上)

Clu*_*ane 31 python unix django gettext internationalization

我正试图让我的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
Run Code Online (Sandbox Code Playgroud)

在终端我得到相同的错误,除非我把它放在我的bash配置文件中:

PATH=$PATH:/Applications/Poedit.app/Contents/MacOS/
Run Code Online (Sandbox Code Playgroud)

但后来我得到了这个错误:

Error: errors happened while running msguniq
/bin/sh: msguniq: command not found os x 
Run Code Online (Sandbox Code Playgroud)

dom*_*nik 98

安装后,尝试链接gettext.这解决了我的问题.

brew install gettext
brew link gettext --force
Run Code Online (Sandbox Code Playgroud)

  • 我不得不在最后一个命令中添加--force. (15认同)

Jak*_*cil 10

我认为你需要安装gettext.Poedit仅包含gettext包提供的一些程序.

可能最简单的安装(不仅仅是)gettext的方法是通过自制软件.安装好自制软件后,运行brew install gettext.在那之后,确保/usr/local/Cellar/gettext/0.18.1.1/bin你的程序在你的$PATH.

请注意,您需要为自制软件安装Xcode才能正常工作,因为它通常从源代码安装软件包(您可以从Mac App Store免费获取Xcode for Lion).

编辑:我忽略了你不使用Lion.对于Snow Leopard,您可以从App Store以5美元的价格购买XCode.我认为LeC的XCode在安装盘上.


Max*_*ysh 7

强迫brew link可能导致负面后果.最好修改虚拟环境的PATH而不是强制链接.所以,

  1. 安装GNU gettext:

    brew install gettext
    
    Run Code Online (Sandbox Code Playgroud)
  2. 将其添加到您的虚拟环境中:

    # 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
    
    Run Code Online (Sandbox Code Playgroud)