Lines 3-8
Link Here
|
3 |
# Parts copyright 2003-2004 Paul Poulain |
3 |
# Parts copyright 2003-2004 Paul Poulain |
4 |
# Parts copyright 2003-2004 Jerome Vizcaino |
4 |
# Parts copyright 2003-2004 Jerome Vizcaino |
5 |
# Parts copyright 2004 Ambrose Li |
5 |
# Parts copyright 2004 Ambrose Li |
|
|
6 |
# Parts copyrigth 2014 Bernardo Gonzalez Kriegel |
6 |
|
7 |
|
7 |
=head1 NAME |
8 |
=head1 NAME |
8 |
|
9 |
|
Lines 24-29
use VerboseWarnings qw( :warn :die );
Link Here
|
24 |
|
25 |
|
25 |
use vars qw( $in_dir @filenames $str_file $out_dir $quiet ); |
26 |
use vars qw( $in_dir @filenames $str_file $out_dir $quiet ); |
26 |
use vars qw( @excludes $exclude_regex ); |
27 |
use vars qw( @excludes $exclude_regex ); |
|
|
28 |
use vars qw( @dirs $match $nomatch ); |
27 |
use vars qw( $recursive_p ); |
29 |
use vars qw( $recursive_p ); |
28 |
use vars qw( $pedantic_p ); |
30 |
use vars qw( $pedantic_p ); |
29 |
use vars qw( $href ); |
31 |
use vars qw( $href ); |
Lines 144-152
sub listfiles {
Link Here
|
144 |
|| (defined $exclude_regex && $dirent =~ /^(?:$exclude_regex)$/)) { |
146 |
|| (defined $exclude_regex && $dirent =~ /^(?:$exclude_regex)$/)) { |
145 |
; |
147 |
; |
146 |
} elsif (-f $path) { |
148 |
} elsif (-f $path) { |
147 |
my $basename = basename $path; |
149 |
my $basename = fileparse( $path ); |
148 |
push @it, $path |
150 |
push @it, $path |
149 |
if ( not @$filenames or ( grep { $path =~ /$_/ } @$filenames ) ) |
151 |
if ( not @$filenames or ( grep { $path =~ /$_/ } @$filenames ) ) |
|
|
152 |
and ( not defined $match or $basename =~ /($match)/i ) # files to include |
153 |
and ( not defined $nomatch or $basename !~ /($nomatch)/i ) # files not to include |
150 |
and (!defined $type || $dirent =~ /\.(?:$type)$/) || $action eq 'install'; |
154 |
and (!defined $type || $dirent =~ /\.(?:$type)$/) || $action eq 'install'; |
151 |
} elsif (-d $path && $recursive_p) { |
155 |
} elsif (-d $path && $recursive_p) { |
152 |
push @it, listfiles($path, $type, $action, $filenames); |
156 |
push @it, listfiles($path, $type, $action, $filenames); |
Lines 194-200
Create or update PO files from templates, or install translated templates.
Link Here
|
194 |
If given, only these files will be processed. |
198 |
If given, only these files will be processed. |
195 |
-s, --str-file=FILE Specify FILE as the translation (po) file |
199 |
-s, --str-file=FILE Specify FILE as the translation (po) file |
196 |
for input (install) or output (create, update) |
200 |
for input (install) or output (create, update) |
197 |
-x, --exclude=REGEXP Exclude files matching the given REGEXP |
201 |
-x, --exclude=REGEXP Exclude dirs matching the given REGEXP |
|
|
202 |
-d, --dir=DIRECTORY Get or update strings from DIRECTORY. Can have |
203 |
multiple values. Using this ignore -i |
204 |
-m, --match=REGEXP Pipe (|) separated list. Include only files |
205 |
matching the given REGEXP. |
206 |
-n, --nomatch=REGEXP Pipe (|) separated list. Exclude all files |
207 |
matching the given REGEXP. |
198 |
--help Display this help and exit |
208 |
--help Display this help and exit |
199 |
-q, --quiet no output to screen (except for errors) |
209 |
-q, --quiet no output to screen (except for errors) |
200 |
|
210 |
|
Lines 223-228
GetOptions(
Link Here
|
223 |
'recursive|r' => \$recursive_p, |
233 |
'recursive|r' => \$recursive_p, |
224 |
'str-file|s=s' => \$str_file, |
234 |
'str-file|s=s' => \$str_file, |
225 |
'exclude|x=s' => \@excludes, |
235 |
'exclude|x=s' => \@excludes, |
|
|
236 |
'dir|d=s' => \@dirs, |
237 |
'match|m=s' => \$match, |
238 |
'nomatch|n=s' => \$nomatch, |
226 |
'quiet|q' => \$quiet, |
239 |
'quiet|q' => \$quiet, |
227 |
'pedantic-warnings|pedantic' => sub { $pedantic_p = 1 }, |
240 |
'pedantic-warnings|pedantic' => sub { $pedantic_p = 1 }, |
228 |
'help' => \&usage, |
241 |
'help' => \&usage, |
Lines 261-267
for my $fn ( @filenames ) {
Link Here
|
261 |
die "You cannot specify input files and directories at the same time.\n" |
274 |
die "You cannot specify input files and directories at the same time.\n" |
262 |
if -d $fn; |
275 |
if -d $fn; |
263 |
} |
276 |
} |
264 |
@in_files = listfiles($in_dir, $type, $action, \@filenames); |
277 |
if ( @dirs ) { # with any -d ignore -i |
|
|
278 |
foreach ( @dirs ) { |
279 |
s/\/$//; |
280 |
@in_files = ( @in_files, listfiles($_, $type, $action, \@filenames)); |
281 |
} |
282 |
} else { |
283 |
@in_files = listfiles($in_dir, $type, $action, \@filenames); |
284 |
} |
265 |
|
285 |
|
266 |
# restores the string list from file |
286 |
# restores the string list from file |
267 |
$href = Locale::PO->load_file_ashash($str_file); |
287 |
$href = Locale::PO->load_file_ashash($str_file); |
Lines 348-354
if ($action eq 'create') {
Link Here
|
348 |
close INPUT; |
368 |
close INPUT; |
349 |
close OUTPUT; |
369 |
close OUTPUT; |
350 |
} |
370 |
} |
351 |
$st = system("msgmerge -U ".($quiet?'-q':'')." -s $str_file $tmpfile2"); |
371 |
$st = system("msgmerge ".($quiet?'-q':'')." -s $str_file $tmpfile2 -o - | msgattrib --no-obsolete -o $str_file"); |
352 |
} else { |
372 |
} else { |
353 |
error_normal "Text extraction failed: $xgettext: $!\n", undef; |
373 |
error_normal "Text extraction failed: $xgettext: $!\n", undef; |
354 |
error_additional "Will not run msgmerge\n", undef; |
374 |
error_additional "Will not run msgmerge\n", undef; |
Lines 377-386
if ($action eq 'create') {
Link Here
|
377 |
if ( @filenames ) { |
397 |
if ( @filenames ) { |
378 |
my ($tmph3, $tmpfile3) = tmpnam(); |
398 |
my ($tmph3, $tmpfile3) = tmpnam(); |
379 |
$st = system("msgcat $str_file $tmpfile2 > $tmpfile3"); |
399 |
$st = system("msgcat $str_file $tmpfile2 > $tmpfile3"); |
380 |
$st = system("msgmerge -U ".($quiet?'-q':'')." -s $str_file $tmpfile3") |
400 |
$st = system("msgmerge ".($quiet?'-q':'')." -s $str_file $tmpfile3 -o - | msgattrib --no-obsolete -o $str_file") |
381 |
unless $st; |
401 |
unless $st; |
382 |
} else { |
402 |
} else { |
383 |
$st = system("msgmerge -U ".($quiet?'-q':'')." -s $str_file $tmpfile2"); |
403 |
$st = system("msgmerge ".($quiet?'-q':'')." -s $str_file $tmpfile2 -o - | msgattrib --no-obsolete -o $str_file"); |
384 |
} |
404 |
} |
385 |
} else { |
405 |
} else { |
386 |
error_normal "Text extraction failed: $xgettext: $!\n", undef; |
406 |
error_normal "Text extraction failed: $xgettext: $!\n", undef; |
387 |
- |
|
|