Skip to content

Parser eats leading and trailing " in comments #6

@reedy

Description

@reedy

Given file foo.po

# "Bar" Something about "Foo"
msgid "Foo"
msgstr "Fop"

Running quotes.php over it (which doesn't change anything of the file itself):

<?php

require_once 'vendor/autoload.php';

$parser = new PoParser\Parser();
$parser->read("foo.po");
$parser->write("foo.po");

Results in:

# Bar" Something about "Foo
msgid "Foo"
msgstr "Fop"

And seemingly the trailing newline too...

diff --git a/locale/foo.po b/locale/foo.po
index 26d2324..1a38546 100644
--- a/locale/foo.po
+++ b/locale/foo.po
@@ -1,3 +1,3 @@
-# "Bar" Something about "Foo"
+# Bar" Something about "Foo
 msgid "Foo"
-msgstr "Fop"
+msgstr "Fop"
\ No newline at end of file

All together:

$ cat foo.po 
# "Bar" Something about "Foo"
msgid "Foo"
msgstr "Fop"
$ cat quotes.php 
<?php

require_once 'vendor/autoload.php';

$parser = new PoParser\Parser();
$parser->read("foo.po");
$parser->write("foo.po");
$ php quotes.php 
$ cat foo.po 
# Bar" Something about "Foo
msgid "Foo"
msgstr "Fop"$

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions