I18n与optik有关 [英] I18n issue with optik

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

问题描述




我写了一个脚本,使用Optik / Optparse显示

选项(工作正常)。帮助消息的文本是本地化的

(使用德语变音符号),当我使用本地化的

环境变量集执行脚本时,我得到了这个追溯[1]。有趣的

的事情是显示的本地化optparse消息很好 -

它只是我的本地化错误。


从我的理解来看,我的剧本并没有发布任何内容,而是这样做的.b
optik / optparse。我的po文件直接从

optik po文件(谁显示正常)复制,所以po文件应该

也可以。


我可以做些什么来解决罪魁祸首是我的脚本,optik

或gettext?


是否有意义发布脚本和mo或po文件?

Thorsten


[1]

Traceback(最近一次调用最后一次):

文件" script.py",第37行,< module>

选项,args = cmdlineparser.parse_args()

文件" /usr/lib/python2.5/optparse.py" ;,第1378行,在parse_args中

stop = self._process_args(largs,rargs,values)

文件" /usr/lib/python2.5/optparse.py" ;,第1418行,在_process_args中

self._process_long_opt(rargs,values)

文件" / usr / lib /python2.5/optparse.py" ;,第1493行,

_process_long_opt

option.process(opt,value,values,self)

文件&quo t; /usr/lib/python2.5/optparse.py" ;,第782行,正在处理

self.action,self.dest,opt,value,values,parser)

文件" /usr/lib/python2.5/optparse.py",第804行,在take_action中

parser.print_help()

文件" / usr / lib / python2.5 / optparse.py",第1648行,在print_help中

file.write(self.format_help()。encode(encoding," replace"))

UnicodeDecodeError:''ascii''编解码器无法解码位置中的字节0xc4

264:序数不在范围内(128)

Hi,

I''ve written a script which uses Optik/Optparse to display the
options (which works fine). The text for the help message is localised
(with german umlauts) and when I execute the script with the localised
environment variable set, I get this traceback[1]. The interesting
thing is that the localised optparse messages from displays fine -
it''s only my localisation that errors.

From my understanding, my script doesn''t put out anything, it''s
optik/optparse who does that. My po file is directly copied from the
optik po file (who displays fine) and modified so the po file should
be fine, too.

What can I do to troubleshoot whether the culprit is my script, optik
or gettext?

Would it make sense to post the script and the mo or po files?
Thorsten

[1]
Traceback (most recent call last):
File "script.py", line 37, in <module>
options, args = cmdlineparser.parse_args()
File "/usr/lib/python2.5/optparse.py", line 1378, in parse_args
stop = self._process_args(largs, rargs, values)
File "/usr/lib/python2.5/optparse.py", line 1418, in _process_args
self._process_long_opt(rargs, values)
File "/usr/lib/python2.5/optparse.py", line 1493, in
_process_long_opt
option.process(opt, value, values, self)
File "/usr/lib/python2.5/optparse.py", line 782, in process
self.action, self.dest, opt, value, values, parser)
File "/usr/lib/python2.5/optparse.py", line 804, in take_action
parser.print_help()
File "/usr/lib/python2.5/optparse.py", line 1648, in print_help
file.write(self.format_help().encode(encoding, "replace"))
UnicodeDecodeError: ''ascii'' codec can''t decode byte 0xc4 in position
264: ordinal not in range(128)

推荐答案

Thorsten Kampe写道:
Thorsten Kampe wrote:

我写了一个脚本,使用Optik / Optparse显示

选项(工作正常)。帮助消息的文本是本地化的

(使用德语变音符号),当我使用本地化的

环境变量集执行脚本时,我得到了这个追溯[1]。有趣的

的事情是显示的本地化optparse消息很好 -

它只是我的本地化错误。


从我的理解来看,我的剧本并没有发布任何内容,而是这样做的.b
optik / optparse。我的po文件直接从

optik po文件(谁显示正常)复制,所以po文件应该

也可以。


我可以做些什么来解决罪魁祸首是我的脚本,optik

或gettext?


是否有意义发布脚本和mo或po文件?
I''ve written a script which uses Optik/Optparse to display the
options (which works fine). The text for the help message is localised
(with german umlauts) and when I execute the script with the localised
environment variable set, I get this traceback[1]. The interesting
thing is that the localised optparse messages from displays fine -
it''s only my localisation that errors.

From my understanding, my script doesn''t put out anything, it''s
optik/optparse who does that. My po file is directly copied from the
optik po file (who displays fine) and modified so the po file should
be fine, too.

What can I do to troubleshoot whether the culprit is my script, optik
or gettext?

Would it make sense to post the script and the mo or po files?



是的,可能。虽然如果你可以将它减少到产生错误的最简单的测试用例

,它会增加你有机会看待它的机会。

看看它。


您也可以尝试发布到optik列表:
http://lists.sourceforge.net/lists/listinfo/optik-users

STeVe

Yes, probably. Though if you can reduce it to the simplest test case
that produces the error, it''ll increase your chances of having someone
look at it.

You could also try posting to the optik list:
http://lists.sourceforge.net/lists/listinfo/optik-users

STeVe


* Steven Bethard(2007年3月31日星期六20:08:45 -0600)
* Steven Bethard (Sat, 31 Mar 2007 20:08:45 -0600)

Thorsten Kampe写道:
Thorsten Kampe wrote:

我写了一个脚本,它使用Optik / Optparse显示

选项(工作正常)。帮助消息的文本是本地化的

(使用德语变音符号),当我使用本地化的

环境变量集执行脚本时,我得到了这个追溯[1]。有趣的

的事情是显示的本地化optparse消息很好 -

它只是我的本地化错误。


从我的理解来看,我的剧本并没有发布任何内容,而是这样做的.b
optik / optparse。我的po文件直接从

optik po文件(谁显示正常)复制,所以po文件应该

也可以。


我可以做些什么来解决罪魁祸首是我的脚本,optik

或gettext?


是否有意义发布脚本和mo或po文件?
I''ve written a script which uses Optik/Optparse to display the
options (which works fine). The text for the help message is localised
(with german umlauts) and when I execute the script with the localised
environment variable set, I get this traceback[1]. The interesting
thing is that the localised optparse messages from displays fine -
it''s only my localisation that errors.

From my understanding, my script doesn''t put out anything, it''s
optik/optparse who does that. My po file is directly copied from the
optik po file (who displays fine) and modified so the po file should
be fine, too.

What can I do to troubleshoot whether the culprit is my script, optik
or gettext?

Would it make sense to post the script and the mo or po files?



是的,可能。虽然如果你可以将它减少到产生错误的最简单的测试用例

,它会增加你有机会看到它的机会



Yes, probably. Though if you can reduce it to the simplest test case
that produces the error, it''ll increase your chances of having someone
look at it.



最简单的test.py是:


###

#! / usr / bin / env python

导入gettext,\

os,\

sys


gettext.textdomain(''optparse'')

gettext.install(''test'')


来自optparse import OptionParser,\

OptionGroup


cmdlineparser = OptionParser(描述= _(''这个软件来了

没有担保,责任或者支持!''))


选项,args = cmdlineparser.parse_args()

###


当我运行LANGUAGE = de ./test.py --help时出现错误。


###这是test.de.po文件

#Copyright(C)2006 Thorsten Kampe

#Thorsten Kampe< th ****** @ thorstenkampe.de>,2006


msgid ""

msgstr""


" Project-Id-Version:Template 1.0 \ n"

POT-Creation-Date:Tue Sep 7 22:20:34 2004\\\


PO-Revision-Date :2005-07-03 16:47 + 0200 \ n"

" Last-Translator:Thorsten Kampe< th ****** @ thorstenkampe.de> \ n"

"语言 - 团队:Thorsten Kampe< th ****** @ thorstenkampe.de> \ n"

" MIME-Version:1.0 \ n"

" Content-Type:text / plain; charset = ISO-8859-15 \ n"

" Content-Transfer-Encoding:8-bit \ nn"

msgstrDIESES PROGRAMM HAT WEDER GEW?#:http://cn HRLEISTUNG,HAFTUNG NOCH
$ b $bUNTERSTüTZUNG!"

###


本地化现在在本地化的optik文件中产生错误,




在Windows下我得到文件G:\program files\python \lib \ encodings

\cp1252.py",第12行,编码

返回codecs.charmap_encode (输入,错误,encoding_table)"


我需要做些什么才能将终端设置为非ascii

输出模式?


我试过了


###

#! / usr / bin / env python

# - * - 编码:ISO-8859-15 - * -


print" DIESES PROGRAMM HAT WEDER GEW? HRLEISTUNG,HAFTUNG NOCH
$ b $bUNTERSTüTZUNG!"

###


....这就有用了。这意味着我的终端愿意打印,

吧?!

The most simple test.py is:

###
#! /usr/bin/env python

import gettext, \
os, \
sys

gettext.textdomain(''optparse'')
gettext.install(''test'')

from optparse import OptionParser, \
OptionGroup

cmdlineparser = OptionParser(description = _(''THIS SOFTWARE COMES
WITHOUT WARRANTY, LIABILITY OR SUPPORT!''))

options, args = cmdlineparser.parse_args()
###

When I run LANGUAGE=de ./test.py --help I get the error.

### This is the test.de.po file
# Copyright (C) 2006 Thorsten Kampe
# Thorsten Kampe <th******@thorstenkampe.de>, 2006

msgid ""
msgstr ""

"Project-Id-Version: Template 1.0\n"
"POT-Creation-Date: Tue Sep 7 22:20:34 2004\n"
"PO-Revision-Date: 2005-07-03 16:47+0200\n"
"Last-Translator: Thorsten Kampe <th******@thorstenkampe.de>\n"
"Language-Team: Thorsten Kampe <th******@thorstenkampe.de>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=ISO-8859-15\n"
"Content-Transfer-Encoding: 8-bit\n"
"Generated-By: pygettext.py 1.5\n"

msgid "THIS SOFTWARE COMES WITHOUT WARRANTY, LIABILITY OR SUPPORT!"
msgstr "DIESES PROGRAMM HAT WEDER GEW?HRLEISTUNG, HAFTUNG NOCH
UNTERSTüTZUNG!"
###

The localisation now produces an error in the localised optik files,
too.

Under Windows I get " File "G:\program files\python\lib\encodings
\cp1252.py", line 12, in encode
return codecs.charmap_encode(input,errors,encoding_table) "

Is there something I have to do to put the terminal in "non-ascii
output mode"?

I tried

###
#! /usr/bin/env python
# -*- coding: ISO-8859-15 -*-

print "DIESES PROGRAMM HAT WEDER GEW?HRLEISTUNG, HAFTUNG NOCH
UNTERSTüTZUNG!"
###

....and this worked. That means that my terminal is willing to print,
right?!


您也可以尝试发布到optik列表:
http://lists.sourceforge.net/lists/listinfo/optik -users



我已经通过Gmane完成了这项工作(虽然这个列表似乎已经死了很多)。 Sourceforge似乎有更大的问题,因为[1]和[2]错误。


对于这种混乱感到抱歉但是这个Unicode魔法远远没有了。
理性。我想大多数人都没有得到它......

Thorsten

[1] http://sourceforge.net/mailarchive/f...um=optik-users

[2] https://lists.sourceforge.net/lists/listinfo


只是一个补充:当我插入此声明时......


print _('''这个软件没有担保,责任或支持!'')


进入这个skript,行打印出来。所以,如果我的Skript可以输出本地化的文本,但是Optparse不应该是一个optparse bug,

对吧?!


Thorsten
Just an addition : when I insert this statement...

print _(''THIS SOFTWARE COMES WITHOUT WARRANTY, LIABILITY OR SUPPORT!'')

into this skript, the line is printed out. So if my Skript can output
the localised text but Optparse can''t it should be an optparse bug,
right?!

Thorsten


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

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