develooper Front page | perl.i18n | Postings from October 2003

xgettext and parameter reordering

Thread Next
Christophe Chisogne
October 6, 2003 03:39
xgettext and parameter reordering
Message ID:

Short question: how can I use standard GNU xgettext for i18n
when using printf parameter reordering ?

In a bit more details:

GNU gettext supports printf parameter reordering, with a syntax
like "%2$d". In C code:

printf(_("I have %1$d houses and %2$d euros"), 2, 2500)

Translated in Perl, the $ must be escaped by '\'. I use " and
not ' because xgettext requires it (no native Perl support).
It becomes

printf(_("I have %1\$d houses and %2\$d euros"), 2, 2500)

My problem is when using standard GNU xgettext to extract
translatable strings. xgettext natively support C and generate
a correct entry in the .po file, with correct translations:

msgid "I have %1$d houses and %2$d euros"

But xgettext doesnt natively supports Perl, and generate
something different, which is not what was intended:

msgid "I have %1\\$d house(s) and %2\\$d euros in my pocket"

Of course, all this lead to untranslated strings.
Is it possible to use standard xgettext without manually
editing the po(t) files it generates, with param reordering?


Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About