In our pipeline, empty comments in po files are generated without
a space after '#' and saving a po file using pofile lib generates
unwanted diff that need to be handle manually which is really annoying.
This pull request simply trim the comment line.
add a blank line in the comments of the headers of the big.po file. This
breaks parsing the headers. msgcat of gettext tools just ignores empty
lines until a header is found and treats everything above as header
comment.
The change to the library itself fixes the tests again, after the blank
linke broke 3.
pofile does not process reference comments in any way, since the format of
references is not exactly specified. This test specifies, what users of
pofile can expect the library to do.
writing messages should no be in line with gettext tools. I tested
using msgcat, it provides the same results.
For some common use-cases I wrote explicit tests, for uncommon and
even unwanted use-cases I wrote one test to make sure pofile works
like msgcat for those messages
in Item.toString, all \n characters are removed from the output.
The gettext tools however leave those characters intact. This
will now produce the same output as tools like msgcat.
An incompatible change (that actually breaks po parsing after writing) had
been introduced with commit e164fcfe9d. If
_process returned an array (which is the case for strings containing \n
character), array.toString will return a comma separated list, which is not
valid po syntax. Added a test to restore the behaviour from before the
e164fcfe9d.
since the lines in the parser have all newline characters removed, \s+ will
not match empty comments.
Added an example that makes other tests fail without this patch.