php-gettext / Gettext

PHP library to collect and manipulate gettext (.po, .mo, .php, .json, etc)
MIT License
689 stars 135 forks source link

Use multiline strings in PO files #114

Open ScreamingDev opened 8 years ago

ScreamingDev commented 8 years ago

Po-Files can have multiline strings:

#. Description of the plugin/theme
msgid ""
"Twenty Sixteen is a modernized take on an ever-popular WordPress layout — "
"the horizontal masthead with an optional right sidebar that works perfectly "
"for blogs and websites. It has custom color options with beautiful default "
"color schemes, a harmonious fluid grid using a mobile-first approach, and "
"impeccable polish in every detail. Twenty Sixteen will make your WordPress "
"look beautiful everywhere."
msgstr ""

This makes it more readable in the IDE than a looooong single-line string.

swissspidy commented 6 years ago

This would need a multibyte safe wordwrap() function that also preserves trailing whitespace.

I mention whitespace because this:

$string = wordwrap('Twenty Sixteen is a modernized take on an ever-popular WordPress layout — the horizontal masthead with an optional right sidebar that works perfectly ', 78);
var_dump(explode("\n", $string));

will result in this:

array(2) {
  [0]=>
  string(75) "Twenty Sixteen is a modernized take on an ever-popular WordPress layout —"
  [1]=>
  string(76) "the horizontal masthead with an optional right sidebar that works perfectly "
}

Note the missing space after the dash.