From 2130e3bee65ca22da74c02d6108d6d3e2c64a188 Mon Sep 17 00:00:00 2001 From: Darold Gilles Date: Mon, 24 Dec 2012 12:52:42 +0100 Subject: [PATCH] Add Locale configuration directive to set the locale when retrieving date from system. Thanks to Klaus Tachtler for the suggestion. --- README | 13 +++++++++++++ SquidAnalyzer.pm | 7 ++++++- doc/SquidAnalyzer.pod | 16 ++++++++++++++- doc/squidanalyzer.3 | 44 ++++++++++++++++++++++++++++++++---------- etc/squidanalyzer.conf | 6 ++++++ 5 files changed, 74 insertions(+), 12 deletions(-) diff --git a/README b/README index fd429a5..308cdb6 100644 --- a/README +++ b/README @@ -234,6 +234,19 @@ CONFIGURATION Allow to change the default unit used to display transfert size. Default is BYTES, other possible values are KB, MB and GB. + MinPie + Minimum percentage of data in pie's graphs to not be placed in the + others item. Lower values will be summarized into the others item. + + Locale + Set this to your locale to display generated date in your language. + Default is to use the current locale of the system. If you want date + in German for example, set it to de_DE. + + Rapport généré le mardi 11 décembre 2012, 15:13:09 (UTC+0100). + + with a Locale set to fr_FR. + AUTHOR Gilles DAROLD diff --git a/SquidAnalyzer.pm b/SquidAnalyzer.pm index 027bb68..b782c78 100644 --- a/SquidAnalyzer.pm +++ b/SquidAnalyzer.pm @@ -410,6 +410,7 @@ sub _init $self->{AnonymizeLogin} = $options{AnonymizeLogin} || 0; $self->{SiblingHit} = $options{SiblingHit} || 1; $self->{ImgFormat} = $options{ImgFormat} || 'png'; + $self->{Locale} = $options{Locale} || ''; if ($self->{Lang}) { open(IN, "$self->{Lang}") or die "ERROR: can't open translation file $self->{Lang}, $!\n"; while (my $l = ) { @@ -1096,7 +1097,11 @@ sub _print_header { my ($self, $fileout, $menu, $calendar) = @_; - my $curdate = `date | iconv -t $Translate{CharSet} 2>/dev/null`; + my $lang = ''; + if ($self->{Locale}) { + $lang = 'LANG=' . $self->{Locale}; + } + my $curdate = `$lang date | iconv -t $Translate{CharSet} 2>/dev/null`; chomp($curdate); my $now = $curdate || strftime("%a %b %e %H:%M:%S %Y", localtime); diff --git a/doc/SquidAnalyzer.pod b/doc/SquidAnalyzer.pod index 211cbbd..732e925 100644 --- a/doc/SquidAnalyzer.pod +++ b/doc/SquidAnalyzer.pod @@ -259,8 +259,22 @@ peer cache hit onto your stats. Allow to change the default unit used to display transfert size. Default is BYTES, other possible values are KB, MB and GB. -=back +=item MinPie +Minimum percentage of data in pie's graphs to not be placed in the others +item. Lower values will be summarized into the others item. + +=item Locale + +Set this to your locale to display generated date in your language. Default +is to use the current locale of the system. If you want date in German for +example, set it to de_DE. + + Rapport généré le mardi 11 décembre 2012, 15:13:09 (UTC+0100). + +with a Locale set to fr_FR. + +=back =head1 AUTHOR diff --git a/doc/squidanalyzer.3 b/doc/squidanalyzer.3 index 68eac94..efff20a 100644 --- a/doc/squidanalyzer.3 +++ b/doc/squidanalyzer.3 @@ -1,4 +1,4 @@ -.\" Automatically generated by Pod::Man 2.22 (Pod::Simple 3.07) +.\" Automatically generated by Pod::Man 2.26 (Pod::Simple 3.07) .\" .\" Standard preamble: .\" ======================================================================== @@ -38,6 +38,8 @@ . ds PI \(*p . ds L" `` . ds R" '' +. ds C` +. ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. @@ -48,17 +50,24 @@ .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. -.ie \nF \{\ -. de IX -. tm Index:\\$1\t\\n%\t"\\$2" +.\" +.\" Avoid warning from groff about undefined register 'F'. +.de IX .. -. nr % 0 -. rr F -.\} -.el \{\ -. de IX +.nr rF 0 +.if \n(.g .if rF .nr rF 1 +.if (\n(rF:(\n(.g==0)) \{ +. if \nF \{ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" .. +. if !\nF==2 \{ +. nr % 0 +. nr F 2 +. \} +. \} .\} +.rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. @@ -124,7 +133,7 @@ .\" ======================================================================== .\" .IX Title "SQUIDANALYZER 1" -.TH SQUIDANALYZER 1 "2012-12-16" "perl v5.10.1" "User Contributed Perl Documentation" +.TH SQUIDANALYZER 1 "2012-12-24" "perl v5.10.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -380,6 +389,21 @@ peer cache hit onto your stats. .IX Item "TransfertUnit" Allow to change the default unit used to display transfert size. Default is \s-1BYTES\s0, other possible values are \s-1KB\s0, \s-1MB\s0 and \s-1GB\s0. +.IP "MinPie" 4 +.IX Item "MinPie" +Minimum percentage of data in pie's graphs to not be placed in the others +item. Lower values will be summarized into the others item. +.IP "Locale" 4 +.IX Item "Locale" +Set this to your locale to display generated date in your language. Default +is to use the current locale of the system. If you want date in German for +example, set it to de_DE. +.Sp +.Vb 1 +\& Rapport gA\*~XnA\*~XrA\*~X le mardi 11 dA\*~Xcembre 2012, 15:13:09 (UTC+0100). +.Ve +.Sp +with a Locale set to fr_FR. .SH "AUTHOR" .IX Header "AUTHOR" Gilles \s-1DAROLD\s0 diff --git a/etc/squidanalyzer.conf b/etc/squidanalyzer.conf index e4eee05..b628451 100644 --- a/etc/squidanalyzer.conf +++ b/etc/squidanalyzer.conf @@ -82,3 +82,9 @@ TransfertUnit BYTES # Minimum percentage of data in pie's graphs to not be placed in the others item. MinPie 2 + +# Set this to your locale to display generated date in your language. Default +# is to use the current locale of the system. If you want date in German for +# example, set it to de_DE. For french, fr_FR should do the work. +#Locale en_US +