Skip to content

simple_po_parser throws an error on multiline strings which do not start with an empty string #3

@mgruner

Description

@mgruner

We have a valid po file generated from Weblate:

❯ msgfmt -c i18n/zammad.zh-cn.po
❯ echo $?
0

It contains such multiline strings, which are obviously valid:

msgid ""
"By default, the follow-up check is done via the subject of an email. This "
"setting lets you add more fields for which the follow-up check will be "
"executed."
msgstr "默认情况下,通过电子邮件的主题进行跟进检查。这个设置允许你增加更多的字段执行"
"跟进检查。"

But they cause the following error:

SimplePoParser::ParserError: SimplePoParser::ParserErrorSyntax error in lines
Syntax error in msgctxt
Syntax error in msgid
Syntax error in msgstr
Unexpected content after expected message end "\"跟进检"
Parseing result before error: '{:reference=>"db/seeds/settings.rb", :msgid=>["", "By default, the follow-up check is done via the subject of an email. This ", "setting lets you add more fields for which the follow-up check will be ", "executed."], :msgstr=>"默认情况下,通过电子邮件的主题进行跟进检查。这个设置允许你增加更多的字段执行"}'
SimplePoParser filtered backtrace: SimplePoParser::ParserError
/usr/local/rvm/gems/ruby-2.7.4/gems/simple_po_parser-1.1.5/lib/simple_po_parser/parser.rb:179:in msgstr'
    from /usr/local/rvm/gems/ruby-2.7.4/gems/simple_po_parser-1.1.5/lib/simple_po_parser/parser.rb:134:inmsgid'
    from /usr/local/rvm/gems/ruby-2.7.4/gems/simple_po_parser-1.1.5/lib/simple_po_parser/parser.rb:114:in msgctxt'
    from /usr/local/rvm/gems/ruby-2.7.4/gems/simple_po_parser-1.1.5/lib/simple_po_parser/parser.rb:51:inlines'
    from /usr/local/rvm/gems/ruby-2.7.4/gems/simple_po_parser-1.1.5/lib/simple_po_parser/parser.rb:75:in comment'
    from /usr/local/rvm/gems/ruby-2.7.4/gems/simple_po_parser-1.1.5/lib/simple_po_parser/parser.rb:49:inlines'
    from /usr/local/rvm/gems/ruby-2.7.4/gems/simple_po_parser-1.1.5/lib/simple_po_parser/parser.rb:25:in parse'
    from /usr/local/rvm/gems/ruby-2.7.4/gems/simple_po_parser-1.1.5/lib/simple_po_parser.rb:19:inparse_message'
    

It seems that such lines are (incorrectly?) expected to be having final white space. Similar multiline strings which contain trailing spaces are processed correctly.

Any help would be appreciated.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions