izimobil / polib

Pure python library to manipulate, create, modify gettext files (pot, po and mo files).
MIT License
102 stars 29 forks source link

When process entry with "#. " above it, error occoured #29

Closed izimobil closed 6 years ago

izimobil commented 12 years ago

Originally reported by: Anonymous


such like

#!gettext

#. translators: reverse the order of these arguments
#. * if the kicked should come before the kicker in your locale.
#. 
#: ../libempathy-gtk/empathy-chat.c:2729
#, c-format
msgid "%1$s was kicked by %2$s"
msgstr "%1$s 被 %2$s 踢出"

izimobil commented 12 years ago

Original comment by David Jean Louis (Bitbucket: izi, GitHub: izi):


I still do not reproduce this issue, all entries starting with "#." are correctly parsed. That said, "#~|" fails, but this is another issue reported here: #28/ioerror-on-reading-obsolete-previous-msgid

Please (@Og Maciel, @rachidbm) if you still reproduce the issue with "#." try to post a reproducible case with a description of your environment (os, python version, etc.). Thanks a lot !

izimobil commented 12 years ago

Original comment by rachidbm (Bitbucket: rachidbm, GitHub: rachidbm):


I got the same error again when the .po file contains comment like: #~| It works when I changed a statement to:

elif (tokens[0] == '#.' or tokens[0] == '#~|')  and nb_tokens >= 1:

Don't know if this will break something else, but for me polib is usable again :)

izimobil commented 12 years ago

Original comment by rachidbm (Bitbucket: rachidbm, GitHub: rachidbm):


I think I have almost the same problem in polib 0.7. When the .po file contains the line "#." parse() terminates with the error:

#!bash
  File "/usr/lib/python2.7/dist-packages/polib.py", line 102, in pofile
    return _pofile_or_mofile(pofile, 'pofile', **kwargs)
  File "/usr/lib/python2.7/dist-packages/polib.py", line 73, in _pofile_or_mofile
    instance = parser.parse()
  File "/usr/lib/python2.7/dist-packages/polib.py", line 1250, in parse
    self.process('??', i)
  File "/usr/lib/python2.7/dist-packages/polib.py", line 1313, in process
    raise IOError('Syntax error in po file (line %s)' % linenum)
IOError: Syntax error in po file (line 4202)
izimobil commented 12 years ago

Original comment by Og Maciel (Bitbucket: omaciel, GitHub: omaciel):


If filename is http://l10n.gnome.org/POT/gnome-terminal.master/gnome-terminal.master.zh_TW.po which is saved locally, then:

In [13]: po = pofile(filename, autodetect_encoding=True, encoding='utf-8') ERROR: An unexpected error occurred while tokenizing input The following traceback may be corrupted or invalid The error message is: ('EOF in multi-line statement', (607, 0))

IOError Traceback (most recent call last) /Library/Python/2.7/site-packages/django/core/management/commands/shell.pyc in () ----> 1 po = pofile(filename, autodetect_encoding=True, encoding='utf-8')

/Library/Python/2.7/site-packages/polib.pyc in pofile(pofile, kwargs) 100 file (optional, default: False). 101 """ --> 102 return _pofile_or_mofile(pofile, 'pofile', kwargs) 103 104 # `

/Library/Python/2.7/site-packages/polib.pyc in _pofile_or_mofile(f, type, **kwargs) 71 check_for_duplicates=kwargs.get('check_for_duplicates', False) 72 ) ---> 73 instance = parser.parse() 74 instance.wrapwidth = kwargs.get('wrapwidth', 78) 75 return instance

/Library/Python/2.7/site-packages/polib.pyc in parse(self) 1248 1249 else: -> 1250 self.process('??', i) 1251 1252 if self.current_entry:

/Library/Python/2.7/site-packages/polib.pyc in process(self, symbol, linenum) 1311 self.current_state = state 1312 except Exception: -> 1313 raise IOError('Syntax error in po file (line %s)' % linenum) 1314 1315 # state handlers

IOError: Syntax error in po file (line 2143)

In [17]: polib.version Out[17]: '0.7.0'

The contents for line 2143 show:

. Translators: This is the label of a menu item to choose a profile.

. * _%c is used as the accelerator (it will be a character between A and Z),

. * and the %s is the name of the terminal profile.

.

: ../src/terminal-window.c:483

, c-format

msgid "%c. %s" msgstr "%c. %s"

izimobil commented 12 years ago

Original comment by David Jean Louis (Bitbucket: izi, GitHub: izi):


I can't reproduce the error with the given sample data...

Please be more explicit, what is the error message ? which version of polib are you running ? etc.

izimobil commented 6 years ago

Close this historic issue