[Templates] i18n with Template-Toolkit (localization, internationalization, multiple languages, multilingual)

Ayhan Ulusoy dev at ulusoy.name
Thu Jul 17 21:07:53 BST 2008


Thank you very much for your responses.

A question comes to my mind.  How do you harvest (extract) the  
messages from the templates into a PO or (POT) file? Do you have to do  
that manually?

I've seen a module on CPAN called Locale::Maketext::Extract which  
comes with a command line utility called "xgettext.pl". This module  
extracts strings from various file formats (Perl, TT, Mason, ...) and  
puts them in a PO file. In its documentation, it says that :

Template Toolkit

     Strings inside [%|l%]...[%END%] or [%|loc%]...[%END%] are  
extracted.


That looks like "loc" would have to be a TT filter for that to work.  
What do you think?

Another question => You say that the folllowing would work as well:

> [% loc('some message') %]
> [% 'some message' | loc %]


Is "loc" an exported function in that case?  Which module exports it  
then?  Besides, how does "loc" know which language handle to use? I am  
perplexed...


Cheers,
Ayhan



On 17 Jul, 2008, at 7:08 PM, Éric Cholet wrote:

> Le 17 juil. 08 à 06:03, Tosh Cooey a écrit :
>
>> So in addition to the methods from Eric:
>> http://mail.template-toolkit.org/pipermail/templates/2008-July/010293.html
>> and Lee:
>> http://mail.template-toolkit.org/pipermail/templates/2008-July/010292.html
>>
>> there's also this from PM: http://www.perlmonks.org/?node_id=466269
>>
>
>
> That's just syntactic sugar though, not a new method. Once you're
> using Locale::MakeText, it's easy to use
>
> [% lh.maketext('some message') %]
> [% loc('some message') %]
> [% 'some message' | loc %]
>
> depending on your aesthetic preference.
>
> --
> Éric Cholet
>
>
>
>
>
> _______________________________________________
> templates mailing list
> templates at template-toolkit.org
> http://mail.template-toolkit.org/mailman/listinfo/templates
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.template-toolkit.org/pipermail/templates/attachments/20080717/b4bdf7b2/attachment.htm 


More information about the templates mailing list