in reply to content negotiation with Apache/cgi
$ENV{HTTP_ACCEPT_LANGUAGE}
my $base_dir_abs = "/var/www/templates"; my $default_lang = 'en'; my $lang = lc $ENV{'HTTP_ACCEPT_LANGUAGE'} my @dirs = ("$base_dir_abs/$default_lang"); if ($lang && $lang ne $default_lang && $lang =~ /^(\w{2})/ # may look like "en-us" && -d "$base_dir_abs/$1") { unshift @dirs, "$base_dir_abs/$1"; } my $tt = Template->new({ INCLUDE_PATH => \@dirs }); $tt->process($file); OR my $ht = HTML::Template->new( filename => $file, path => \@dirs, );
# Your directory structure may look like /var/www/templates/en/my_cgi/index.html /var/www/templates/en/my_cgi/step2.html /var/www/templates/en/my_cgi/step3.html /var/www/templates/en/another_cgi/index.html /var/www/templates/sp/my_cgi/index.html /var/www/templates/sp/my_cgi/step2.html /var/www/templates/sp/another_cgi/index.html
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: content negotiation with Apache/cgi
by punkish (Priest) on Apr 25, 2007 at 02:06 UTC |