xgettext - PHP multiline strings

xgettext doesn't consider more texts concatenated using the dot operator in the PHP script as a single string and thus it splits them as separate entries in the .po file.

This patch fixes this bug. There are several limitations:

  • Only quoted texts can be concatenated (they can contain variables), it's NOT possible to concatenate a quoted text and a variable

    RIGHT: $x = "text1" . "text2 $variable";

    WRONG: $x = "text1" . $variable;

  • In case of multiline texts, it's NOT possible to use a comment between the parts of the text

    RIGHT: $x = _("text1".


  • WRONG: $x = _("text1". // first line

  • Only texts quoted with the same type of qoutes can ce concatenated.

    RIGHT: $x = "text1" . "text2"; // double-quotes

    WRONG: $x = "text1" . 'text2'; // double-quote and single quote

Althou there are few limitations this patch is quite good as it allows to split long texts to more lines and concatenate the with the dot.


Filename Version Type OS
gettext-x-php-concat.diff 0.16.1 Patch Un*x
Patch was developed on the gettext 0.14.6, it was successfully tested with the gettext 0.16.1. It should be possible to use with ohter versions.
© 2018 any code