[Catalyst] I18N with variables

Cosimo Streppone cosimo at streppone.it
Fri Aug 6 12:44:38 GMT 2010


On Mon, 02 Aug 2010 07:08:04 +0200, Julien Sobrier <julien at sobrier.net>  
wrote:

> Also, writing [% c.loc(foo) %] does not create an entry in messages.po
> when running xgettext.pl, like [% c.loc('foo') %] does.

To make that work, I think you'd have to actually *run*
your templates for all possible cases, and then collect all
the strings that were passed as arguments to c.loc().

In other words, I'm not saying it's impossible, but
xgettext.pl will probably never be able to do that.

A slightly different approach, that works for me,
is to create your .PO files in different stages.

First step parses the templates with xgettext.pl and generates
the .PO files.

A second step can, for example, parse the actual source
code, for stuff like '$c->loc("foo")'.
xgettext.pl can do that with a bit of trickery.

The new messages will be merged together in the same .PO files.

In your case, you could pull the messages you want to be translated
directly from the database, and write some on-the-fly
fake templates (or text files for that matter),
and feed them to xgettext.pl.

-- 
Cosimo



More information about the Catalyst mailing list