gettext [英] gettext again

查看:63
本文介绍了gettext的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我没能使它工作但却找不到什么是错的。这就是

我这样做:


================

test.py

import gettext

gettext.install('''')


msg = _(没有重音字符的消息)


打印消息

================


然后我这样做:


xgettext test.py

mv message.po message pot


msginit - >输出message.fr_FR@euro


我用这段文字编辑我的fr_FR @ euro:

msgid"这是一条没有重音符号的消息。 br />
msgstr"消息aveccaractèresaccentués:éèàù?ê?? aa?"


然后msgfmt fr_FR @ euro


然后python test.py显示没有重音字符的消息


为什么?我正在做什么有什么问题?


感谢您的帮助。

Hi,
I''m failing to make it work but can''t find out what''s wrong. Here''s what
I do :

================
test.py

import gettext
gettext.install('''')

msg = _("Message without accented characters")

print msg
================

Then I do :

xgettext test.py

mv message.po message pot

msginit --> output message.fr_FR@euro

I edit my fr_FR@euro with this text :
msgid "This is a message without accented characters."
msgstr "Message avec caractères accentués : éèàù?ê??aa?"

Then msgfmt fr_FR@euro

Then python test.py shows "Message without accented characters"

How come ? What''s wrong with what I am doing ?

Thanks for your help.

推荐答案

On太阳,2005年8月7日11:09:14 +0200,cantabile写道:
On Sun, 07 Aug 2005 11:09:14 +0200, cantabile wrote:

我没能让它工作但却找不到怎么了。这就是我做的事情:
[....]为什么会这样?我正在做什么有什么问题?
Hi,
I''m failing to make it work but can''t find out what''s wrong. Here''s what
I do : [....] How come ? What''s wrong with what I am doing ?



从这个关于gettext的小方法开始。
http://childsplay.sourceforge.net/translate-howto.html


然后在test.py中执行此操作:
http://www.python.org/doc/2.4.1/lib/node330.html

您应该阅读Python库参考中关于gettext的部分

它真的很好:-)


祝你好运,

Stas Z


Start with this little howto about gettext.
http://childsplay.sourceforge.net/translate-howto.html

And then do this in your test.py:
http://www.python.org/doc/2.4.1/lib/node330.html

You should read the part about gettext in the Python Library Reference
it''s really good :-)

Good luck,
Stas Z

< br>

staszaécrit:
stasz a écrit :
On Sun,2005年8月7日11:09:14 +0200,cantabile写道:

On Sun, 07 Aug 2005 11:09:14 +0200, cantabile wrote:


我没能使它工作但却找不到什么是错的。这就是我做的事情:
Hi,
I''m failing to make it work but can''t find out what''s wrong. Here''s what
I do :



[....]



[....]

为什么会这样?我正在做什么有什么问题?
How come ? What''s wrong with what I am doing ?



从这个关于gettext的小方法开始。
http://childsplay.sourceforge.net/translate-howto.html

然后在你的test.py:
http:// www.python.org/doc/2.4.1/lib/node330.html

您应该阅读Python库参考中关于gettext的部分
它真的好的:-)
祝你好运,
Stas Z



Start with this little howto about gettext.
http://childsplay.sourceforge.net/translate-howto.html

And then do this in your test.py:
http://www.python.org/doc/2.4.1/lib/node330.html

You should read the part about gettext in the Python Library Reference
it''s really good :-)

Good luck,
Stas Z




好​​吧,我一定是傻了,因为我确实如此,它仍然没有工作......


BTW,我没有pygettext模块。我在这里问过,有人说它已经被弃用了,现在已经包含在xgettext中了。

我已经阅读了关于gettext的Python文档大约十次,但似乎

相当过时,因为它调用pygettext(如上面所示)...


我已经阅读了gettext的信息页面(相当长的工作) 。


这里又是我的test1.py文件:


============== =============

导入gettext,os,locale

locale.setlocale(locale.LC_ALL)

gettext.install(''test1.py'',''/ usr / share / locale'')

msg = _("这是一条消息没有重音字符。)


打印消息

===================== ======


我现在能做什么?



Well, I must be dumb, because I did exactly that and it still doesn''t
work...

BTW, I have no pygettext module. I asked here and somebody said it was
deprecated and now included in xgettext.
And I''ve read the Python doc about gettext about ten times, but it seems
quite outdated since it calls pygettext (as staded above)...

I''ve read the info pages of gettext too (quite a long work).

Here''s my test1.py file again :

===========================
import gettext, os, locale

locale.setlocale(locale.LC_ALL)
gettext.install(''test1.py'', ''/usr/share/locale'')

msg = _("This is a message without accented characters.")

print msg
===========================

What can I do now ?


On Sun,2005年8月7日21:33:21 +0200,cantabile写道:
On Sun, 07 Aug 2005 21:33:21 +0200, cantabile wrote:
staszaécrit:
stasz a écrit :
On Sun,2005年8月7日11:09:14 +0200,cantabile写道:

On Sun, 07 Aug 2005 11:09:14 +0200, cantabile wrote:


我没能使它工作但却找不到什么是错的。这就是我做的事情:
[....]
Hi,
I''m failing to make it work but can''t find out what''s wrong. Here''s what
I do :
[....]
为什么会这样?我正在做什么有什么问题?
How come ? What''s wrong with what I am doing ?



从这个关于gettext的小方法开始。
http://childsplay.sourceforge.net/translate-howto.html

然后在你的test.py:
http:// www.python.org/doc/2.4.1/lib/node330.html

您应该阅读Python库参考中关于gettext的部分
它真的好的:-)
祝你好运,
Stas Z



Start with this little howto about gettext.
http://childsplay.sourceforge.net/translate-howto.html

And then do this in your test.py:
http://www.python.org/doc/2.4.1/lib/node330.html

You should read the part about gettext in the Python Library Reference
it''s really good :-)

Good luck,
Stas Z



好吧,我必须愚蠢,因为我做到了这一点,它仍然没有工作......

顺便说一句,我没有pygettext模块。我在这里问过,有人说它已被弃用,现在已经包含在xgettext中了。
我已经阅读了关于gettext的Python文档大约十次了,但它似乎已经过时了,因为它调用了pygettext(如上所述)...

我已经阅读了gettext的信息页面(相当长的工作)。



Well, I must be dumb, because I did exactly that and it still doesn''t
work...

BTW, I have no pygettext module. I asked here and somebody said it was
deprecated and now included in xgettext.
And I''ve read the Python doc about gettext about ten times, but it seems
quite outdated since it calls pygettext (as staded above)...

I''ve read the info pages of gettext too (quite a long work).



好​​的,你应该使用xgettext从test1.py创建一个.po文件。

翻译该文件并使用msgfmt将其编译成.mo文件。

复制此.mo文件到/ usr / share / locale / fr / LC_MESSAGES /

这里再次是我的test1.py文件:

========== =================
导入gettext,os,locale

locale.setlocale(locale.LC_ALL)
gettext.install (''test1.py'',''/ usr / share / locale'')


Ok, you should use xgettext to create a .po file from your test1.py.
Translate that file and use msgfmt to compile it into a .mo file.
Copy this .mo file to /usr/share/locale/fr/LC_MESSAGES/
Here''s my test1.py file again :

===========================
import gettext, os, locale

locale.setlocale(locale.LC_ALL)
gettext.install(''test1.py'', ''/usr/share/locale'')



test1.py错误,您必须提供.mo文件的名称。

必须是:gettext.install(''test1.mo'',''/ usr / share / locale'')

假设你有cal像这样领导了莫文件。


Stas Z


test1.py is wrong, you must give the name of the .mo file.
It must be: gettext.install(''test1.mo'', ''/usr/share/locale'')
Assuming you have called the mo file like that.

Stas Z


这篇关于gettext的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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