【发布时间】:2014-04-28 23:49:08
【问题描述】:
我正在尝试翻译一个字符串。
{% load i18n %}
{% trans "Well, Hello there, how are you?" %}
到...
Hola amigo, ¿que tal?
我的 settings.py 文件有这个:
LOCALE_PATHS = (
os.path.join(BASE_DIR, 'translations'),
)
我得到了这个:
(env)glitch:translations nathann$ django-admin.py compilemessages
CommandError: Can't find msgfmt. Make sure you have GNU gettext tools 0.15 or newer installed.
我也不明白这个错误信息。
(env)glitch:ipals nathann$ django-admin.py makemessages -l es
CommandError:
This script should be run from the Django Git tree or your project or
app tree. If you did indeed run it from the Git checkout or your project
or application, maybe you are just missing the conf / locale(in the
django tree) or locale(for project and application) directory? It is not
created automatically, you have to create it by hand if you want to
enable i18n for your project or application.
文档:https://docs.djangoproject.com/en/1.6/ref/django-admin/#django-admin-makemessages
对于奖金投票,一个相关的问题: 当我安装它时,gettext 没有链接......对此有任何帮助吗?我应该强迫它吗?
glitch:translations nathann$ brew link gettext
Warning: gettext is keg-only and must be linked with --force
Note that doing so can interfere with building software.
谢谢!
更新:
我已经将翻译的名称更改为语言环境并相应地更新了我的 settings.py。然后我再次运行它,它仍然在抱怨 gettext:
(env)glitch:ipals nathann$ mv translations/ locale
(env)glitch:ipals nathann$ django-admin.py makemessages -l es
CommandError: Can't find xgettext. Make sure you have GNU gettext tools 0.15 or newer installed.
我还发现了这个:
Understand homebrew and keg-only dependencies
读完后:
(env)glitch:ipals nathann$ brew install gettext
Warning: gettext-0.18.3.2 already installed
(env)glitch:ipals nathann$ brew link gettext
Warning: gettext is keg-only and must be linked with --force
Note that doing so can interfere with building software.
【问题讨论】:
标签: python django homebrew gettext