develooper Front page | perl.i18n | Postings from November 2005

Re: long strings and xgettext.pl

Thread Previous | Thread Next
From:
Guido Flohr
Date:
November 4, 2005 03:08
Subject:
Re: long strings and xgettext.pl
Message ID:
436B4124.4070202@imperia.net
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

Sava Chankov wrote:
| However, they doesn't look good in indented code. So I split them in
smaller strings, as C gettext allows:
|
| _(   "If you want to receive mail in the folder, add addresses."
|      "A message sent to an address that you add will be delivered to
the folder."
|      "If you don't want to receive mail in the folder, click 'Next'
button"
|      "You will still be able to drag'n'drop messages into it."
| );
|
| Unfortunately, xgettext.pl [or Locale::Maketext::Extract::extract, to
be precise] doesn't understand that gettext is variadic function and the
result looks like this (comment
| line truncated by me to 80 characters):

The code is syntactically wrong.  You have to concatenate the strings by
the dot operator:

_("If you ..."
~  . "A message ..."
~  . "If you ..."
~  etc.

But Locale::Maketext:::Extract will still only extract the first part of
the message because it does not handle the concatenation operator.

You should give the standard C version of gettext a try.  Beginning with
version 1.12 GNU gettext supports Perl, and it recognizes almost all
string types that Perl knows, for example:

print _<<EOF;
If you ...
A message ...
If you ...
EOF

Just try "xgettext yourscript.pl YourModule.pm ..."

BTW, gettext() is not a variadic function, neither in Perl nor in C.  It
takes exactly one argument, the msgid.

Still BTW, it is generally a bad idea to use a single underscore as an
alias for gettext().  That function is automatically global.

Regards,
Guido
- --
Imperia AG, Development
Leyboldstr. 10 - D-50354 Hürth - http://www.imperia.net/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)

iD8DBQFDa0EiOo0HNPWNDz0RAmKbAKCC1Y+hzw05icMYQ6wfBIV0/xLyzQCgln+o
UzU1fiP8iF1buvBRZ2APrw8=
=mWnr
-----END PGP SIGNATURE-----


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About