Message205361
When having non ascii chars in the header of an translation file (xxx.po) the following error will be raised:
File "D:\Python33\lib\gettext.py", line 410, in translation
t = _translations.setdefault(key, class_(fp))
File "D:\Python33\lib\gettext.py", line 160, in __init__
self._parse(fp)
File "D:\Python33\lib\gettext.py", line 265, in _parse
item = b_item.decode().strip()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe4 in position 51: invalid continuation byte
translation file head:
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2013-12-06 11:47\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE+Mitteleuropäische Zeit\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=utf-8\n"
"Content-Transfer-Encoding: utf-8\n"
"Generated-By: pygettext.py 1.5\n"
The problem here exists with the PO-Revision-Date which is followed by the timezone offset in current language (here "Mitteleuropäische Zeit") which is automatically added by pygettext.py.
When removing it the file will work without any problems.
Current pygettext.py code part:
[Line 444] ...
def write(self, fp):
options = self.__options
timestamp = time.strftime('%Y-%m-%d %H:%M+%Z')
# The time stamp in the header doesn't have the same format as that
# generated by xgettext...
print(pot_header % {'time': timestamp, 'version': __version__}, file=fp)
...
To avoid this it would be better to use gmtime and not to append the timezone:
...
def write(self, fp):
options = self.__options
timestamp = time.strftime('%Y-%m-%d %H:%M', time.gmtime())
... |
|
Date |
User |
Action |
Args |
2013-12-06 11:20:33 | Michael.Müller | set | recipients:
+ Michael.Müller |
2013-12-06 11:20:33 | Michael.Müller | set | messageid: <1386328833.52.0.797354581277.issue19907@psf.upfronthosting.co.za> |
2013-12-06 11:20:33 | Michael.Müller | link | issue19907 messages |
2013-12-06 11:20:32 | Michael.Müller | create | |
|