An alternative is to look at the problem from a different perspective. If
you can keep your content and data separate then you can consider having
different templates for different languages.
For example, I might have a series of templates:
index.tmpl
index.en-gb.tmpl
index.fr.tmpl
and I could use the appropriate one depending on browser language settings:
{
# Get appropriate language template
my $t = MakeTemplate ($self, 'index');
}
sub MakeTemplate
{
my ($self, $name, $args) = @_;
my $languages = $ENV{HTTP_ACCEPT_LANGUAGE} || '';
my $template;
foreach my $language (split (/,/, lc $languages)) {
$template = "$name.$language.tmpl";
last if -s $template;
if ($language =~ /^(.*)?-/) {
$template = "$name.$1.tmpl";
last if -s $template;
}
}
$template = "$name.tmpl" if ! -s $template;
return $self->load_tmpl ($template, @args);
}
It's perhaps not the most elegant code I've ever written, but you're welcome
to it if it's any use.
Chris
--
Chris Davies, Manheim Online
Tel. 0113 393-2004 Fax. 0870 444-0482. Mobile 07778 199069
-----Original Message-----
From: simran [mailto:[EMAIL PROTECTED]]
Sent: Friday, June 07, 2002 8:50 AM
To: [EMAIL PROTECTED]
Subject: Re: [htmltmpl] Handling Different Languages (Language Support)
[...]
I was hoping that HTML::Template had some internally supported
mechanism, so that we could when we load a template file, let it know
the location of our "Language data file" and then at run-time, run
something like:
my $template = new HTML::Template(file => 'test.tmpl', ...)
$template->languageFiles(directory => '/path/to/data/files');
$template->setLanguage(language => 'en-au', guess => 1);
# implying that if a translation is not found for
'en-au' then try 'en', etc...
$template->output();
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]