Autrijus Tang wrote: >>xgettext.pl gives wrong ..%2\\$d.. with src code like "..%2$d.." > > I think you mean "%2\$d"? If that's the case, it can be fixed. Yes, I really mean xgettext.pl gives wrong ..%2\\$d.. with src code like "..%2\$d.." But it can't be fixed, now I think better, due to different syntaxes --- xgettext.pl already does the Right Thing : 1. std xgettext want(ed) translatable strings between dble quotes as there is(was) no native Perl support. To use xgettext, src code must be like src: _("...") or gettext("...") to use std ("old") xgettext 2. gettext catalogs files (.po) always uses "..." to surround strings and force escaping \ with \\. With a "..%1\d.." in .po catalog, msgfmt refuse to make the .mo file saying "file.po:x:y: invalid control sequence". So we end up with "..%1\\$d.." in catalog if we want \ in it. But then, no translation take place, the correct syntax beeing only "..%1$d.." in .po file: .po: "..%1\\$d.." invalid, must use "..%1$d.." to get translations 3. in Perl, a $ inside " must be escaped with \ to avoid substitutions. perl: "..%1$d.." invalid, must use "..%1\$d.." or '..%1$d..' We clearly see incompatibilities here. To get std gettext translation with param reordering in Perl, we can NOT use the double quotes (") in Perl src code: xgettext.pl in fact does the right thing by replacing \ with \\ when using " in src code, as required by the GNU .po catalogs syntax. In brief, to get translation with param reordering in Perl using std GNU gettext lib: 1. Mark src code strings with '..%1$d..' syntax (no double quotes) 2. To extract them, use xgettext.pl which does the Right Thing (tm) or xgettext with Perl support (only in CVS for now) I'm asking myself if all this shouldnt be documented somewhere, along with different options to do "automatic" i18n in Perl (std gettext, Maketext, Maketext::Lexicon, libintl-perl, whatever) Time to add entries for "See Also" in perllocale(1) ? Locale::gettext, http://www.gnu.org/manual/gettext/ Locale::Maketext Locale::Maketext::Lexicon, http://www.autrijus.org/webl10n/webl10n.html Locale::TextDomain aka libintl-perl ... ChristopheThread Previous | Thread Next