Django makemessages错误未知编码“utf8” [英] Django makemessages errors Unknown encoding "utf8"

查看:340
本文介绍了Django makemessages错误未知编码“utf8”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里搜索和google也是!但是没有成功找到解决方案,我真的没有python,但可以安装从yum分离的python。



现在,我需要重新编译语言包OSQA系统,但收到以下消息:

 错误:在__init__.py上运行xgettext时发生错误
xgettext: ./Django-1.2.3/tests/regressiontests/views/__init__.py:1:未知编码utf8。以ASCII代替。
xgettext:非ASCII字符串./Django-1.2.3/tests/regressiontests/views/__init__.py:7。
请通过--from代码或通过http://www.python.org/peps/pep-0263.html中指定的注释
指定源代码编码。

我尝试了,但没有成功解决它,在utf-8中设置编码。 py文件,但没有成功。



有人可以给我一个灯光来解决吗? :(



谢谢,最好的问候!

解决方案

我已经和makemessages有类似的问题,因为在每个源文件之上,我写了#编码:utf8,尽管它与源代码编译一起工作,但我不得不用utf-8替换utf8在每个文件中。



如果您不习惯使用makemessages,请注意应用于格式化字符串的gettext函数,当有更多的字符串时,您将需要字符串来包含命名参数超过一个占位符
%s是好的
%(最大)s也很好
%(最小)s%(最大)s太
%s%s不行。


I searched here and google too! But no success finding the solution, I'm really noob with python but could be able to install python separated from yum.

Now, I need to recompile the language pack for the OSQA system, but get this message:

Error: errors happened while running xgettext on __init__.py
xgettext: ./Django-1.2.3/tests/regressiontests/views/__init__.py:1: Unknown encoding "utf8". Proceeding with ASCII instead.
xgettext: Non-ASCII string at ./Django-1.2.3/tests/regressiontests/views/__init__.py:7.
          Please specify the source encoding through --from-code or through a comment
          as specified in http://www.python.org/peps/pep-0263.html.

I tryed, but had no success to solve it, set encode at utf-8 in the manage.py file but no success too.

Can someone give me a light to solve it? :(

Thanks, and best regards!

解决方案

Actually yes, I've already had similar problems with makemessages, because on top of every source file I wrote "# coding: utf8". Even though it worked with source compilation, I've had to replace "utf8" with "utf-8" in every file.

If you're not used to makemessages, take care of gettext functions applied to format strings, you will need strings to contain named parameters when there is more than one placeholder. "%s" is good "%(max)s" is good too "%(min)s %(max)s" too "%s %s" is not ok.

这篇关于Django makemessages错误未知编码“utf8”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆