xgettext & multiline string literals

View: New views
2 Messages — Rating Filter:   Alert me  

xgettext & multiline string literals

by Georg.Steffers :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

First of all hello to this list!

I am searching for this quite some time, but still could not find any
answer.
I use gettext in my C programs with no problems some time now. So
I decided to do the same with my web projects.
It was a nearly painless start, with only one exception. I am not able
to use multiline string literals for slightly longer texts in PHP.

In C i can use the following:

_("This is just a slightly longer "
  "text for demontration purpose");

To split one long string into (what i called) a multiline string literal.
This
works perfectly, at least with gcc and xgettext does extract the whole
string (both lines) as a key.
In PHP this is not possible at all because it simply does not allow this
syntactically.
So i tried the following in PHP:

_("This is just a slightly longer " .
  "text for demontration purpose");

But that is not understood by xgettext. The .po file does only
contain the first row of the string as a key.

Has anyone any solution for this?


Best regards
   Georg Steffers

Antwort: [PHP-I18N] xgettext & multiline string literals (addition)

by Georg.Steffers :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Georg.Steffers@... schrieb am 26.10.2006 10:50:31:

# snip #

> _("This is just a slightly longer " .
>   "text for demontration purpose");
>
> But that is not understood by xgettext. The .po file does only
> contain the first row of the string as a key.

additionally i tried:

_("This is just a slightly longe
  text for demonstration purpose");

This results in the same behaviour as with C the string literal
includes all whitespace characters including \n \t or whatever...
Thatfor these are also part of the key extracted by xgettext.
This is a horror to read in the .po file and makes the stuff
difficult to translate.
And it is for sure inacceptable if the string will be used for
other purpose than write it within a HTML ducoment.

BR
  Georg
LightInTheBox - Buy quality products at wholesale price!