I just uploaded an update to Unicode::MapUTF8 to CPAN that includes Japanese POD docs (kindly translated by 川合孝典 AKA Kawai Takanori). While the module has been superceded by Encode for Perl 5.8 and later, it still serves a valuable purpose for people still running older versions of Perl.

The problem is that POD, Module::Build and MakeMaker all seem to have no concept of I18n (internationalization) what-so-ever. They expect one .pod per package, and that POD can only be in one language/encoding.

I did a lot of Googling, poked around CPAN for other people's solutions. No two people seem to do it the same way and none of their solutions appear to install the locale appropriate POD for the module under the module's main name. I finally did something new to me: Hacked Build.PL and Makefile.PL to 'magically' swap the locale appropriate .pod for the main .pod when you run 'perl ./Build.PL' or 'perl ./Makefile.PL'.

The basic trick was to insert the following into Build.PL and Makefile.PL before their regular configuration sections:

use File::Copy qw (copy); my $lang = defined($ENV{'LANG'}) ? $ENV{'LANG'} : 'en'; my $target_pod = File::Spec->catfile('lib','Unicode','MapUTF8.pod'); if ($lang =~ m/^(ja|ja_JP|ja_JP.utf-8|ja_JP.utf8|ja.utf8|ja.utf-8)$/i) + { $source_pod = File::Spec->catfile('pod','MapUTF8.ja_JP.utf8.pod'); copy ($source_pod, $target_pod); } elsif ($lang =~ m/^(ja_JP.eucjp|ja_JP.euc|ja_euc|ja_eucjp)$/i) { $source_pod = File::Spec->catfile('pod','MapUTF8.ja_JP.eucjp.pod') +; copy ($source_pod, $target_pod); } else { $source_pod = File::Spec->catfile('pod','MapUTF8.en.pod'); copy ($source_pod, $target_pod); }

This seems like a workable hack to install locale appropriate translated docs and it sucessfully installed on everything I tested from Perl 5.005 to Perl 5.8.6 on Fedora.

Comments? Improvements? Horrified reactions?


In reply to I18n and POD by snowhare

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.