From b025be7b869c06a774c09c92170c060bd9e1b179 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Tue, 3 Dec 2002 02:59:13 +0000 Subject: Have support for translated templates Use CSS - they need to be trimmed, I don't like Sergiusz's colors thesaurusindexfile and indexfilebasename config values should not longer have the extension (.html) in them --- Echolot/Tools.pm | 68 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 31 deletions(-) (limited to 'Echolot/Tools.pm') diff --git a/Echolot/Tools.pm b/Echolot/Tools.pm index 7a83049..20ae504 100644 --- a/Echolot/Tools.pm +++ b/Echolot/Tools.pm @@ -1,7 +1,7 @@ package Echolot::Tools; # (c) 2002 Peter Palfrader -# $Id: Tools.pm,v 1.11 2002/10/25 10:47:54 weasel Exp $ +# $Id: Tools.pm,v 1.12 2002/12/03 02:59:13 weasel Exp $ # =pod @@ -205,37 +205,43 @@ sub write_meta_information($%) { }; sub write_HTML_file($$;$%) { - my ($file, $template_file, $expire, %templateparams) = @_; - - my $template = HTML::Template->new( - filename => $template_file, - strict => 0, - die_on_bad_params => 0, - global_vars => 1 ); - $template->param ( %templateparams ); - $template->param ( CURRENT_TIMESTAMP => scalar gmtime() ); - $template->param ( SITE_NAME => Echolot::Config::get()->{'sitename'} ); - $template->param ( separate_rlist => Echolot::Config::get()->{'separate_rlists'} ); - $template->param ( combined_list => Echolot::Config::get()->{'combined_list'} ); - $template->param ( thesaurus => Echolot::Config::get()->{'thesaurus'} ); - $template->param ( version => Echolot::Globals::get()->{'version'} ); - $template->param ( expires => date822( time + $expire )); - - open(F, '>'.$file) or - cluck("Cannot open $file: $!\n"), - return 0; - print F $template->output() or - cluck("Cannot print to $file: $!\n"), - return 0; - close (F) or - cluck("Cannot close $file: $!\n"), - return 0; - - if (defined $expire) { - write_meta_information($file, - Expires => time + $expire) or - cluck ("Error while writing meta information for $file"), + my ($origfile, $template_file, $expire, %templateparams) = @_; + + for my $lang ( keys %{Echolot::Config::get()->{'templates'}} ) { + my $template = HTML::Template->new( + filename => Echolot::Config::get()->{'templates'}->{$lang}->{$template_file}, + strict => 0, + die_on_bad_params => 0, + global_vars => 1 ); + $template->param ( %templateparams ); + $template->param ( CURRENT_TIMESTAMP => scalar gmtime() ); + $template->param ( SITE_NAME => Echolot::Config::get()->{'sitename'} ); + $template->param ( separate_rlist => Echolot::Config::get()->{'separate_rlists'} ); + $template->param ( combined_list => Echolot::Config::get()->{'combined_list'} ); + $template->param ( thesaurus => Echolot::Config::get()->{'thesaurus'} ); + $template->param ( version => Echolot::Globals::get()->{'version'} ); + $template->param ( expires => date822( time + $expire )); + + my $file = $origfile; + $file .= '.'.$lang unless ($lang eq 'default'); + $file .= '.html'; + + open(F, '>'.$file) or + cluck("Cannot open $file: $!\n"), return 0; + print F $template->output() or + cluck("Cannot print to $file: $!\n"), + return 0; + close (F) or + cluck("Cannot close $file: $!\n"), + return 0; + + if (defined $expire) { + write_meta_information($file, + Expires => time + $expire) or + cluck ("Error while writing meta information for $file"), + return 0; + }; }; return 1; -- cgit v1.2.3