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

xgettext and parameter reordering

Thread Next
From:
Christophe Chisogne
Date:
October 6, 2003 03:39
Subject:
xgettext and parameter reordering
Message ID:
3F81464E.3070600@publicityweb.com

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?

Christophe


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