Johan Kuuse <suppressed> wrote:
> To keep things separated, there is a problem:
>
> 1. If, on one hand, I want to use one single HTML::Template for the output in
> different languages, the template itself cannot have any "fixed strings" in
> one languages, but has to be filled up only with <TMPL_VAR NAME=xxx> tags for
> every single message.
> This makes the job tougher for the web designer (the web page preview will be
> almost unreadable).
>
> 2. If, on the other hand, one HTML::Template per language, the translator has
> to know some HTML to create a HTML::Template with "fixed strings" in her/his
> language. And this means that the web designer will end up with one template
> per language, which also is undesirable.
[disclaimer: I don't have any real experience with internationalization
and the web, or with Petal for that mater, so take all this with a
shaker of salt.]
If you're not completely committed to using HTML::Template you might
consider experimenting with the Petal template engine. With Petal, you
can include placeholder text in your template that will be replaced with
the real content when the template is filled:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html xmlns:tal="http://purl.org/petal/1.0/">
<head>
<title tal:content="hello_world">Hello, World!</title>
</head>
<body>
<b><span tal:replace="hello_world">Hello, World!</span></b>
<p tal:content="welcome">Welcome to this website.</p>
</body>
</html>
In your application, you set the template variables 'hello_world' and
'welcome' to the language-specific values.
my $template = Petal->new('template.xhtml');
return $template->process(
hello_world => '¡Hola,mundo!',
welcome => 'Bienvenido a este sitio web.',
);
And the result is:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<title>¡Hola,mundo!</title>
</head>
<body>
<b>¡Hola,mundo!</b>
<p>Bienvenido a este sitio web.</p>
</body>
</html>
The clever bit is that your template is valid HTML with English
placeholder text, so your web designers can still preview the pages in a
web browser.
Here are some caveats based on my limited experience with Petal: first
off it requires properly formated xhtml, so your designers have to be
more careful that way. Secondly, it doesn't perform quite as well as
HTML::Template or Template::Toolkit do. Petal::CodePerl claims to
make Petal go faster, but I haven't tried it).
Michael
-----------------------------------------------------------------------
Michael Graham <suppressed>
YAPC::NA 2005 Toronto - http://www.yapc.org/America/ - suppressed
-----------------------------------------------------------------------
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/suppressed/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed
Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.