From: Enrico Sorcinelli Date: Wed, 30 Sep 2009 07:56:07 +0000 (+0200) Subject: Make Pod::Perldoc use PERLDOC_POD2 ENV var X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=83298dfc8d92e012de41ae52193e2fd7e2bcbd84;p=p5sagit%2Fp5-mst-13.2.git Make Pod::Perldoc use PERLDOC_POD2 ENV var * The "PERLDOC_POD2" environment variable could be used, to set once, the preferred translation (instead of using "-L" switch each time). eg. export PERLDOC_POD2=it If "PERLDOC_POD2=1", the language code will be auto-retrieved from locale, that is, from "LC_ALL" "LC_LANG" "LANG" environment variables respectively. export PERLDOC_POD2=1 * bug fix: -f switch works correctly with missing translations. * bug fix: perldoc now correctly works with several translators --- diff --git a/ext/Pod-Perldoc/lib/Pod/Perldoc.pm b/ext/Pod-Perldoc/lib/Pod/Perldoc.pm index 97edc25..2dbb5d8 100644 --- a/ext/Pod-Perldoc/lib/Pod/Perldoc.pm +++ b/ext/Pod-Perldoc/lib/Pod/Perldoc.pm @@ -12,7 +12,7 @@ use File::Spec::Functions qw(catfile catdir splitdir); use vars qw($VERSION @Pagers $Bindir $Pod2man $Temp_Files_Created $Temp_File_Lifetime ); -$VERSION = '3.15'; +$VERSION = '3.15_01'; #.......................................................................... BEGIN { # Make a DEBUG constant very first thing... @@ -658,8 +658,11 @@ sub options_processing { $self->opt_n("nroff") unless $self->opt_n; $self->add_formatter_option( '__nroffer' => $self->opt_n ); + # Get language from PERLDOC_POD2 environment variable + $self->opt_L || ( $ENV{PERLDOC_POD2} eq '1' ? $self->_elem('opt_L',(split(/\_/, $ENV{LC_ALL} || $ENV{LC_LANG} || $ENV{LANG}))[0] ) : $self->_elem('opt_L', $ENV{PERLDOC_POD2}) ); + # Adjust for using translation packages - $self->add_translator($self->opt_L) if $self->opt_L; + $self->add_translator(split(/\s+/,$self->opt_L)) if $self->opt_L; return; } @@ -966,7 +969,9 @@ sub search_perlfunc { print "Going to perlfunc-scan for $search_re in $perlfunc\n"; my $re = 'Alphabetical Listing of Perl Functions'; - if ( $self->opt_L ) { + + # Check available translator or backup to default (english) + if ( $self->opt_L && defined $self->{'translators'}->[0] ) { my $tr = $self->{'translators'}->[0]; $re = $tr->search_perlfunc_re if $tr->can('search_perlfunc_re'); }