On Jul 17, 2008, at 1:07 PM, Ayhan Ulusoy wrote:

> 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?

We're doing it manually to have better control over what's going on.   
IIRC xgettext.pl only supports the syntax you mentioned and not the [%  
"foo" | loc %] syntax which sometimes is more convenient. It also  
doesn't preserve comments.  In the scheme of things maintaining the  
files semi-manually isn't as much hassle as it sounds.

>
>> [% 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...

It's setup as a filter.


Another variation is to use the TT include paths to have the system  
search multiple paths.  We have it setup so when TT is looking for  
"foobar/template.html" it'll look for

    docs/en/foobar/template.html
    docs/foobar/template.html

(actually, we have a bunch more overrides for brands and such - but  
you get the idea).

That way we can easily put in language specific templates for pages  
that have big blocks of text rather than stuffing it all into .po files.


  - ask

-- 
http://develooper.com/ - http://askask.com/

_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates

Reply via email to