|
做了个中英文切换的测试,在命令行下执行就正常,在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 "编辑" |
|