Re: HTML::Template and Locale::Maketext

Hugues de Mazancourt <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.html-template
Message-ID <[email protected]>
Hi,

Just about <TMPL_xxx > tags in the template file: don't forget that you 
can use H::T's 'filter' option and thus define your own syntax. 
Personally, I've turned all the <TMPL_x > into a {%... %} notation, so 
that '<TMPL_VAR NAME="foo">' now reads '{%VAR NAME="foo"%}' in my 
templates. This works in Dreamweaver (at least a my translator's 
version).

As I suggested, you can use this kind of filter to "hide" calls to 
maketext (or whatever localisation method) into a more web-designer 
friendly way. For example you could use {{ ... }} to hide <TMPL_VAR 
EXPR=maketext('...')>. This could yield to:


<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<title>{{Hello, world!}}></title>
</head>
<body>
<b>{{Hello, world!}}></b>
<p>{{Welcome to this website.}}></p>
<!-- We could use H::T variables to have things like this : -->
<p>{{We have [quant,_1,visitor] today,, visitor_count}}></p> </body>
</html>

(definition of the filter is left as an exercise to the reader ;-)

A a side effect, this can help the designer keep in mind that all text 
chunks will be localised independently, so that he/she should avoid 
things like:

<TR>
  <TD>{{Do you want}}</TD>
  <TD>{{to}}
    <select name="action"><option value="del">{{delete}}</option><option 
value="keep">{{keep}}</option></select>
</TD>
<TR>

Where "to" would have to be translated using some unambiguous 
correspondence which doesn't exist for every languages (at least for 
French, this "to" would disappear - in other contexts, not).


Best,

Hugues


PS: I know that this doesn't solve the cache issue, as template is 
re-evaluated for every display, so that you should mix this approach 
with Mark's caching modifications.


-------------------------------------------------------
This SF.Net email is sponsored by Yahoo.
Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
Search APIs Find out how you can build Yahoo! directly into your own
Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.