|
Lines 22-28
use VerboseWarnings qw( :warn :die );
Link Here
|
| 22 |
|
22 |
|
| 23 |
############################################################################### |
23 |
############################################################################### |
| 24 |
|
24 |
|
| 25 |
use vars qw( $in_dir @filenames $str_file $out_dir $quiet ); |
25 |
use vars qw( @in_dirs @filenames $str_file $out_dir $quiet ); |
| 26 |
use vars qw( @excludes $exclude_regex ); |
26 |
use vars qw( @excludes $exclude_regex ); |
| 27 |
use vars qw( $recursive_p ); |
27 |
use vars qw( $recursive_p ); |
| 28 |
use vars qw( $pedantic_p ); |
28 |
use vars qw( $pedantic_p ); |
|
Lines 185-191
Usage: $0 create [OPTION]
Link Here
|
| 185 |
or: $0 --help |
185 |
or: $0 --help |
| 186 |
Create or update PO files from templates, or install translated templates. |
186 |
Create or update PO files from templates, or install translated templates. |
| 187 |
|
187 |
|
| 188 |
-i, --input=SOURCE Get or update strings from SOURCE directory. |
188 |
-i, --input=SOURCE Get or update strings from SOURCE directory(s). |
|
|
189 |
On create or update can have multiple values. |
| 190 |
On install only one value. |
| 189 |
-o, --outputdir=DIRECTORY Install translation(s) to specified DIRECTORY |
191 |
-o, --outputdir=DIRECTORY Install translation(s) to specified DIRECTORY |
| 190 |
--pedantic-warnings Issue warnings even for detected problems |
192 |
--pedantic-warnings Issue warnings even for detected problems |
| 191 |
which are likely to be harmless |
193 |
which are likely to be harmless |
|
Lines 199-208
Create or update PO files from templates, or install translated templates.
Link Here
|
| 199 |
-q, --quiet no output to screen (except for errors) |
201 |
-q, --quiet no output to screen (except for errors) |
| 200 |
|
202 |
|
| 201 |
The -o option is ignored for the "create" and "update" actions. |
203 |
The -o option is ignored for the "create" and "update" actions. |
| 202 |
Try `perldoc $0 for perhaps more information. |
204 |
Try `perldoc $0` for perhaps more information. |
| 203 |
EOF |
205 |
EOF |
| 204 |
exit($exitcode); |
206 |
exit($exitcode); |
| 205 |
}#` |
207 |
} |
| 206 |
|
208 |
|
| 207 |
############################################################################### |
209 |
############################################################################### |
| 208 |
|
210 |
|
|
Lines 217-223
sub usage_error (;$) {
Link Here
|
| 217 |
############################################################################### |
219 |
############################################################################### |
| 218 |
|
220 |
|
| 219 |
GetOptions( |
221 |
GetOptions( |
| 220 |
'input|i=s' => \$in_dir, |
222 |
'input|i=s' => \@in_dirs, |
| 221 |
'filename|f=s' => \@filenames, |
223 |
'filename|f=s' => \@filenames, |
| 222 |
'outputdir|o=s' => \$out_dir, |
224 |
'outputdir|o=s' => \$out_dir, |
| 223 |
'recursive|r' => \$recursive_p, |
225 |
'recursive|r' => \$recursive_p, |
|
Lines 239-253
$SIG{__WARN__} = sub {
Link Here
|
| 239 |
|
241 |
|
| 240 |
my $action = shift or usage_error('You must specify an ACTION.'); |
242 |
my $action = shift or usage_error('You must specify an ACTION.'); |
| 241 |
usage_error('You must at least specify input and string list filenames.') |
243 |
usage_error('You must at least specify input and string list filenames.') |
| 242 |
if !$in_dir || !defined $str_file; |
244 |
if !@in_dirs || !defined $str_file; |
| 243 |
|
245 |
|
| 244 |
# Type match defaults to *.tt plus *.inc if not specified |
246 |
# Type match defaults to *.tt plus *.inc if not specified |
| 245 |
$type = "tt|inc|xsl|xml|def" if !defined($type); |
247 |
$type = "tt|inc|xsl|xml|def" if !defined($type); |
| 246 |
|
248 |
|
| 247 |
# Check the inputs for being directories |
249 |
# Check the inputs for being directories |
| 248 |
usage_error("$in_dir: Input must be a directory.\n" |
250 |
for my $in_dir ( @in_dirs ) { |
| 249 |
. "(Symbolic links are not supported at the moment)") |
251 |
usage_error("$in_dir: Input must be a directory.\n" |
| 250 |
unless -d $in_dir; |
252 |
. "(Symbolic links are not supported at the moment)") |
|
|
253 |
unless -d $in_dir; |
| 254 |
} |
| 251 |
|
255 |
|
| 252 |
# Generates the global exclude regular expression |
256 |
# Generates the global exclude regular expression |
| 253 |
$exclude_regex = '(?:'.join('|', @excludes).')' if @excludes; |
257 |
$exclude_regex = '(?:'.join('|', @excludes).')' if @excludes; |
|
Lines 255-267
$exclude_regex = '(?:'.join('|', @excludes).')' if @excludes;
Link Here
|
| 255 |
my @in_files; |
259 |
my @in_files; |
| 256 |
# Generate the list of input files if a directory is specified |
260 |
# Generate the list of input files if a directory is specified |
| 257 |
# input is a directory, generates list of files to process |
261 |
# input is a directory, generates list of files to process |
| 258 |
$in_dir =~ s/\/$//; # strips the trailing / if any |
|
|
| 259 |
|
262 |
|
| 260 |
for my $fn ( @filenames ) { |
263 |
for my $fn ( @filenames ) { |
| 261 |
die "You cannot specify input files and directories at the same time.\n" |
264 |
die "You cannot specify input files and directories at the same time.\n" |
| 262 |
if -d $fn; |
265 |
if -d $fn; |
| 263 |
} |
266 |
} |
| 264 |
@in_files = listfiles($in_dir, $type, $action, \@filenames); |
267 |
for my $in_dir ( @in_dirs ) { |
|
|
268 |
$in_dir =~ s/\/$//; # strips the trailing / if any |
| 269 |
@in_files = ( @in_files, listfiles($in_dir, $type, $action, \@filenames) ); |
| 270 |
} |
| 265 |
|
271 |
|
| 266 |
# restores the string list from file |
272 |
# restores the string list from file |
| 267 |
$href = Locale::PO->load_file_ashash($str_file); |
273 |
$href = Locale::PO->load_file_ashash($str_file); |
|
Lines 394-399
if ($action eq 'create') {
Link Here
|
| 394 |
usage_error("You must specify an output directory when using the install method."); |
400 |
usage_error("You must specify an output directory when using the install method."); |
| 395 |
} |
401 |
} |
| 396 |
|
402 |
|
|
|
403 |
if ( scalar @in_dirs > 1 ) { |
| 404 |
usage_error("You must specify only one input directory when using the install method."); |
| 405 |
} |
| 406 |
|
| 407 |
my $in_dir = shift @in_dirs; |
| 408 |
|
| 397 |
if ($in_dir eq $out_dir) { |
409 |
if ($in_dir eq $out_dir) { |
| 398 |
warn "You must specify a different input and output directory.\n"; |
410 |
warn "You must specify a different input and output directory.\n"; |
| 399 |
exit -1; |
411 |
exit -1; |
| 400 |
- |
|
|