summaryrefslogtreecommitdiff
path: root/Echolot/Tools.pm
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2002-12-03 02:59:13 +0000
committerPeter Palfrader <peter@palfrader.org>2002-12-03 02:59:13 +0000
commitb025be7b869c06a774c09c92170c060bd9e1b179 (patch)
tree3cad523b5adcd6c22243ecb1724873a7ec6e44f7 /Echolot/Tools.pm
parenta5a75de615b8e131c4be7f3f12c2b293fa997ae3 (diff)
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
Diffstat (limited to 'Echolot/Tools.pm')
-rw-r--r--Echolot/Tools.pm68
1 files changed, 37 insertions, 31 deletions
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 <peter@palfrader.org>
-# $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;