LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1274|回复: 0

问个python i18n的问题

[复制链接]
发表于 2007-1-24 18:54:46 | 显示全部楼层 |阅读模式
做了个中英文切换的测试,在命令行下执行就正常,在eclips+pdev下运行就出错,提示错误:  File "C:\Documents and Settings\Administrator\Desktop\testtt\src\test.py", line 9, in <module>
    print _("File")
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)
直接print "中文"就能正常显示
修改coding utf-8 和gb.po的Content-Transfer-Encoding: cp936都无效.
文件:test.py如下:
# -*- coding: GBK -*-
#!/usr/bin/env python


import gettext
gettext.install('gb', './locale', unicode=False)
gettext.translation('gb', './locale', languages=['cn']).install(True)

print _("File")
#print "中文"

翻译文件gb.po如下:
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"roject-Id-Version: PACKAGE VERSION\n"
"OT-Creation-Date: 2007-01-18 09:55+China Standard Time\n"
"O-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=gb2312\n"
"Content-Transfer-Encoding: GBK\n"
"Generated-By: pygettext.py 1.5\n"

#
msgid "File"
msgstr "文件"

msgid "Edit"
msgstr "编辑"
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表