SYNOPSIS

    use POD2::Base;
    $pod2 = POD2::Base->new({ lang => 'EO' });

    @dirs = $pod2->pod_dirs;
    $re = $pod2->search_perlfunc_re;

DESCRIPTION

This module is an abstraction of the code in \s-1POD2::IT\s0 and \s-1POD2::FR\s0. These modules belong to the Italian and the French translation projects of core Perl pods.

Once a translation package had been installed, the translated documentation can be accessed with:

$ perldoc POD2::<lang>::<podname>

(where <lang> is a language abbreviation like \s-1IT\s0, \s-1FR\s0, \s-1TLH\s0, etc.)

This is guaranteed to work even for older versions of perldoc. It is not very convenient but always works.

To improve the support to read translated docs, the perldoc utility (since version 3.14_01) was updated to find translated PODs via:

$ perldoc -L IT <podpage> $ perldoc -L FR -f <function> $ perldoc -L TH -q <FAQregex>

(Note: this support was shipped together with the recently released 5.10.0 version the Perl interpreter.)

The objective of this class is to provide a minimum base to help \*(C`perldoc\*(C' and authors of translation packages to do their job.

SUBCLASSING

If you want to write a translation package (and have some customization needs), your work may be diminished if you subclass \*(C`Pod::Base\*(C'.

For example, a minimum example is provided below:

package POD2::TLH; # Klingon

use POD2::Base; our @ISA = qw( POD2::Base );

sub search_perlfunc_re { # makes 'perldoc -f' work return 'Klingon Listing of Perl Functions'; }

1;

And then

$ perldoc -L tlh perlintro

will present you the introduction of Perl in Klingon language (provided a POD2/TLH/perlintro.pod file was shipped together with \s-1POD2/TLH\s0.pm) and

$ perldoc -L tlh -f pack

will find you the Klingon documentation of \*(C`pack\*(C' (if POD2/TLH/perlfunc.pod was made available as well).

METHODS

This module has been made into a proper class with a very small \s-1API\s0.

new

$pod2 = POD2::Base->new(\%args); $pod2 = POD2::ANY->new(); The constructor. An actual call might look like this: $pod2 = POD2::Base->new({ lang => 'tlh' }); where the supported options are:

  • \*(L"lang\*(R" Specifies the language code we're interested in. This is required, but can be extracted from the name of a subclass. Read below.

  • \*(L"inc\*(R" This is used to override the list of Perl library directories where \s-1POD\s0 documents are searched (namely, @INC). Most of the time, you don't want to mess with that. It's handy for debugging and testing. It must be an array ref.

If \*(C`POD2::ANY\*(C' is a subclass of \*(C`POD2::Base\*(C', the inherited constructor will work without arguments pulling '\s-1ANY\s0' from the package name and using it as the intented language code. Note that use of \*(L"inc\*(R" in the constructor freezes the list of library dirs searched by the \*(C`POD2::Base\*(C' instance. If this is not used, the up-to-date @INC is used at each call of \*(C`pod_dirs\*(C' (so that dynamic changes in the Perl library path are taken into account). That's what we meant with the \*(L"Most of the time, you don't want to mess with that\*(R" mentioned above.

pod_dirs

@dirs = $pod2->pod_dirs; @dirs = $pod2->pod_dirs(\%options); Used by \*(C`Pod::Perldoc\*(C' to find out where to look for translated pods. The \*(C`POD2::Base\*(C' default behavior is to find POD2/<lang>/ directories under the current Perl library directories (@INC) or the list given as argument \*(L"inc\*(R" in the constructor. The supported options are:

  • \*(L"test\*(R" By default, the return of \*(C`pod_dirs\*(C' do not include \s-1POD\s0 directories which do not exist (tested with \*(C`-d\*(C'). If an explicit false value for this option (like \*(C`test => 0\*(C') is given, such test is not done and \*(C`pod_dirs\*(C' includes all possible candidates POD2/<lang>/ under the library directories. (Handy for debugging this module. Not much practical use for anything else.)

search_perlfunc_re

$re = $pod2->search_perlfunc_re; To implement \*(C`perldoc -f <function>\*(C' the current code of \*(C`Pod::Perldoc\*(C' uses a hard coded string \*(L"Alphabetical Listing of Perl Functions\*(R" or the return of this method (in a regexp) to skip the introduction and reach the listing of core functions. Thus a translation package with a corresponding translated perlfunc.pod should define this method to make \*(C`perldoc -L <lang> -f <function>\*(C' work properly.

There are other methods documented below. However, they will probably be superseded in future versions when more general methods to find and display metadata on translated PODs are designed and implemented.

pod_info

$hashref = $pod2->pod_info; Used by \*(C`POD2::Base\*(C' itself. The return contains some metadata on the translated PODs which is used by the methods \*(C`print_pod\*(C' and \*(C`print_pods\*(C'. When subclassing, you should override this with the current information on what \s-1POD\s0 translations the current package is providing.

print_pods

$pod2->print_pods; Prints all translated pods and the corresponding Perl version of the original files.

print_pod

$pod2->print_pod(@pages); $pod2->print_pod(); # uses @ARGV Prints the corresponding Perl version of the original files corresponding to the pods passed as arguments.

EXAMPLES

\s-1POD2::TLH\s0

A slightly extended version of \*(C`POD2::TLH\*(C' goes like this:

package POD2::TLH; # Klingon

use POD2::Base; our @ISA = qw( POD2::Base );

sub search_perlfunc_re { return 'Klingon Listing of Perl Functions'; }

sub pod_info { return { perlintro => '5.8.8' }; }

1;

And you may try:

use POD2::TLH; my $pod2 = 'POD2::TLH'; $pod2->print_pods(); $pod2->print_pod('pod_foo', 'pod_baz', ...);

\s-1THE\s0 \s-1INSTALLED\s0 \s-1FILES\s0

If you want to find out which language-specific \s-1POD\s0 files are installed at your Perl, you could use a code similar to this.

use File::Find; use POD2::Base;

my $pod2 = POD2::Base->new({ lang => $lang });

my @files; find sub { push @files, $File::Find::name } if -f }, $pod2->pod_dirs; print "$_\n" for @files;

In the \*(C`POD2-Base\*(C' distribution tarball, a script eg/list.pl is included with an improved version of this code.

The rules of finding \s-1POD\s0 in .pod, .pm files and others belong to Pod::Perldoc. So \*(C`POD2::Base\*(C' do not try to repeat them here.

AUTHORS

Enrico Sorcinelli <bepi at perl.it> (the original \s-1POD2::IT\s0 code)

Adriano Ferreira <ferreira at cpan.org>

RELATED TO POD2::Base…

\s-1POD2::IT\s0, \s-1POD2::FR\s0, \s-1POD2::LT\s0, \s-1POD2::CN\s0, perldoc, perl.

COPYRIGHT AND LICENCE

Copyright (C) 2004-2006 Perl.it / Perl Mongers Italia

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.