[Catalyst] I18N and TT question

Octavian Rasnita orasnita at gmail.com
Mon Jul 25 10:22:04 GMT 2011


From: "Alex Povolotsky" <tarkhil at over.ru>

> Hello!
>
> How do I define a macro for localization GLOBALLY? I don't like to add 
> MACRO to every template, nor I don't want to write c.localize() instead of 
> l()
>
> Alex



I use the following settings in the app configuration file:

'View::TT' => {
    PRE_PROCESS => ['locale_date_datetime.tt'],
};

And in the template locale_date_datetime.tt I put:

[% MACRO l(text,args) BLOCK; c.localize(text,args) || text; END ~%]

This template is loaded automaticly and in any other template I can use:

[% l('Text to translate') %]

or

 [% l('Text to [_1] translate [_2]', [var1, var2]) %]

In the same template locale_date_datetime.tt I also use other global macros 
for printing the DateTime dates in different formats so it can be used for 
other things also...

Octavian




More information about the Catalyst mailing list