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?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: I18n and POD
by xdg (Monsignor) on Oct 10, 2005 at 21:43 UTC | |
|
Re: I18n and POD
by Anonymous Monk on Oct 11, 2005 at 01:32 UTC |