Django 国际化 - Gettext 错误

Coh*_*hen 5 python django

我正在用 Django 构建一个站点。下载 gettext-0.19.8.tar.gz ---> /Users/cohen/Downloads/gettext-0.19.8 并运行所有步骤后 ./configure make 和 sudo make installation 我在安装过程中收到此错误 python manage .py makemessages -l en

在安装之前,Gettext 部分的一切都运行得很顺利。我使用的是 MAC,使用 Pycharm 作为我的 IDE。请指教!

PS有一种方法可以通过gettext安装来生成消息吗?

谢谢!

xgettext: ./venv/lib/python3.6/site-packages/pip-9.0.1-py3.6.egg/pip/_vendor/webencodings/__init__.py:1: Unknown encoding "utf8". Proceeding with ASCII instead.
xgettext: Non-ASCII string at ./venv/lib/python3.6/site-packages/pip-9.0.1-py3.6.egg/pip/_vendor/webencodings/__init__.py:64.
          Please specify the source encoding through --from-code or through a comment
          as specified in http://www.python.org/peps/pep-0263.html.
Run Code Online (Sandbox Code Playgroud)

为什么我收到这个错误。我无法使用此命令进行正确的翻译

我跟着这个培训: Django国际化最小的例子

http://www.marinamele.com/taskbuster-django-tutorial/internationalization-localization-languages-time-zones

https://gist.github.com/mbilard/1647940

后期编辑:在 virtualenv 中重新安装 gettext 后,我​​收到此错误:

make[4]: Nothing to be done for `install-exec-am'.
 ../build-aux/install-sh -c -d '/Users/cohen/PycharmProjects/gettext/share/doc/gettext/examples/build-aux'
 /usr/bin/install -c -m 644 ../build-aux/javacomp.sh.in ../build-aux/javaexec.sh.in ../build-aux/csharpcomp.sh.in ../build-aux/csharpexec.sh.in '/Users/cohen/PycharmProjects/gettext/share/doc/gettext/examples/build-aux'
 ../build-aux/install-sh -c -d '/Users/cohen/PycharmProjects/gettext/share/gettext'
 /usr/bin/install -c ../build-aux/config.rpath '/Users/cohen/PycharmProjects/gettext/share/gettext'
make[3]: Nothing to be done for `install-exec-am'.
make[3]: Nothing to be done for `install-data-am'.
Run Code Online (Sandbox Code Playgroud)

以及 make 检查结果:gettext-tools 0.19.8 的测试套件摘要

> ============================================================================
> # TOTAL: 198
> # PASS:  187
> # SKIP:  10
> # XFAIL: 0
> # FAIL:  1
> # XPASS: 0
> # ERROR: 0
> ============================================================================ See gnulib-tests/test-suite.log Please report to
> bug-gnu-gettext@gnu.org
> ============================================================================ make[7]: *** [test-suite.log] Error 1 make[6]: *** [check-TESTS] Error
> 2 make[5]: *** [check-am] Error 2 make[4]: *** [check-recursive] Error
> 1 make[3]: *** [check] Error 2 make[2]: *** [check-recursive] Error 1
> make[1]: *** [check-recursive] Error 1 make: *** [check] Error 2
Run Code Online (Sandbox Code Playgroud)

Sco*_*hio 0

我宁愿通过Homebrew安装它,而不是自己构建它- 从长远来看,它使事情更容易维护:

brew install gettext
Run Code Online (Sandbox Code Playgroud)

如果它抱怨类似的事情

警告:gettext 仅限桶,必须与 --force 链接

你需要跑

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

然后它应该可以正常工作。(如果仍然没有,请重建 virtualenv。)