Changeset 5618
- Timestamp:
- 06/26/09 17:28:08 (3 years ago)
- Location:
- trunk/Locale-Msgfmt
- Files:
-
- 3 edited
-
Changes (modified) (1 diff)
-
bin/msgfmt.pl (modified) (1 diff)
-
lib/Locale/Msgfmt.pm (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Locale-Msgfmt/Changes
r5608 r5618 1 1 Revision history for Locale-Msgfmt 2 3 0.07 Jun 26, 2009 4 make the interface a bit nicer 2 5 3 6 0.06 Jun 26, 2009 -
trunk/Locale-Msgfmt/bin/msgfmt.pl
r5528 r5618 10 10 GetOptions("output-file|o=s" => \$opt_o, "use-fuzzy|f" => \$opt_f); 11 11 my $in = shift; 12 if(!(defined($in) && defined($opt_o))) {13 print "usage: $0 [-f] -o output.mo input.po\n";14 exit(1);15 }16 12 17 13 msgfmt({in => $in, out => $opt_o, fuzzy => $opt_f}); -
trunk/Locale-Msgfmt/lib/Locale/Msgfmt.pm
r5611 r5618 17 17 sub msgfmt { 18 18 my $hash = shift; 19 if(!defined($hash)) { 20 die("error: must give input"); 21 } 22 if(!(ref($hash) eq "HASH")) { 23 $hash = {in => $hash}; 24 } 25 if(!defined($hash->{in}) or !length($hash->{in})) { 26 die("error: must give an input file"); 27 } 28 if(! -e $hash->{in}) { 29 die("error: input does not exist"); 30 } 31 if(-d $hash->{in}) { 32 return _msgfmt_dir($hash); 33 } else { 34 return _msgfmt($hash); 35 } 36 } 37 38 sub msgfmt_dir { 39 return msgfmt(@_); 40 } 41 42 sub _msgfmt { 43 my $hash = shift; 44 if(! defined($hash->{in})) { 45 die("error: must give an input file"); 46 } 19 47 if(! -f $hash->{in}) { 20 print "error: input file does not exist\n"; 21 exit(1); 48 die("error: input file does not exist"); 49 } 50 if(! defined($hash->{out})) { 51 if($hash->{in} =~ /\.po$/) { 52 $hash->{out} = $hash->{in}; 53 $hash->{out} =~ s/po$/mo/; 54 } else { 55 die("error: must give an output file"); 56 } 22 57 } 23 58 my $mo = Locale::Msgfmt::mo->new(); … … 29 64 } 30 65 31 sub msgfmt_dir {66 sub _msgfmt_dir { 32 67 my $hash = shift; 33 68 if(! -d $hash->{in}) { 34 print "error: input directory does not exist\n"; 35 exit(1); 69 die("error: input directory does not exist"); 36 70 } 37 71 if(! defined($hash->{out})) { … … 57 91 $newhash{in} = $_; 58 92 $newhash{out} = $files{$_}; 59 msgfmt(\%newhash);93 _msgfmt(\%newhash); 60 94 } 61 95 } … … 75 109 76 110 msgfmt({in => "po/fr.po", out => "po/fr.mo"}); 77 msgfmt_dir({in => "po/"}); 111 msgfmt({in => "po/fr.po", out => "po/fr.mo", fuzzy => 1}); 112 msgfmt("po/"); 113 msgfmt({in => "po/", out => "output/"}); 114 msgfmt("po/fr.po"); 115 msgfmt({in => "po/fr.po", fuzzy => 1}); 78 116 79 117 =head1 COPYRIGHT & LICENSE
Note: See TracChangeset
for help on using the changeset viewer.
