Changeset 5547
- Timestamp:
- 06/24/09 22:30:16 (3 years ago)
- Location:
- trunk/Locale-Msgfmt
- Files:
-
- 2 edited
-
Changes (modified) (1 diff)
-
lib/Locale/Msgfmt.pm (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Locale-Msgfmt/Changes
r5540 r5547 1 1 Revision history for Locale-Msgfmt 2 3 0.02 UNRELEASED 4 - add a msgfmt_dir function to convert all of the .po files in a directory 2 5 3 6 0.01 Jun 24, 2009 -
trunk/Locale-Msgfmt/lib/Locale/Msgfmt.pm
r5526 r5547 3 3 use Locale::Msgfmt::mo; 4 4 use Locale::Msgfmt::po; 5 use File::Path; 6 use File::Spec; 5 7 6 8 use strict; … … 9 11 use base 'Exporter'; 10 12 11 our @EXPORT = qw/msgfmt /;13 our @EXPORT = qw/msgfmt msgfmt_dir/; 12 14 13 15 our $VERSION = '0.01'; … … 27 29 } 28 30 31 sub msgfmt_dir { 32 my $hash = shift; 33 if(! -d $hash->{in}) { 34 print "error: input directory does not exist\n"; 35 exit(1); 36 } 37 if(! defined($hash->{out})) { 38 $hash->{out} = $hash->{in}; 39 } 40 if(! -d $hash->{out}) { 41 File::Path::mkpath($hash->{out}); 42 } 43 opendir D, $hash->{in}; 44 my @list = readdir D; 45 closedir D; 46 @list = grep /\.po$/, @list; 47 my %files; 48 foreach(@list) { 49 my $in = File::Spec->catfile($hash->{in}, $_); 50 my $out = File::Spec->catfile($hash->{out}, substr($_, 0, -3) . ".mo"); 51 $files{$in} = $out; 52 } 53 delete $hash->{in}; 54 delete $hash->{out}; 55 foreach(keys %files) { 56 my %newhash = (%{$hash}); 57 $newhash{in} = $_; 58 $newhash{out} = $files{$_}; 59 msgfmt(\%newhash); 60 } 61 } 62 29 63 1; 30 64 … … 40 74 use Locale::Msgfmt; 41 75 42 msgfmt({in => "po/fr.po", out => "po/fr.mo"}) 76 msgfmt({in => "po/fr.po", out => "po/fr.mo"}); 77 msgfmt_dir({in => "po/"}); 43 78 44 79 =head1 COPYRIGHT & LICENSE
Note: See TracChangeset
for help on using the changeset viewer.
