Changeset 5092
- Timestamp:
- 2003-08-04T16:11:57+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/bin/script/mkcol.pl
r4873 r5092 89 89 90 90 my $options = { 'name' => "mkcol.pl", 91 'desc' => " PERL script used to create the directory structure for a new Greenstone collection.",91 'desc' => "{mkcol.desc}", 92 92 'args' => $arguments }; 93 93 … … 101 101 print STDERR "<Info>\n"; 102 102 print STDERR " <Name>$options->{'name'}</Name>\n"; 103 print STDERR " <Desc> $options->{'desc'}</Desc>\n";103 print STDERR " <Desc>" . &lookup_string($options->{'desc'}) . "</Desc>\n"; 104 104 print STDERR " <Arguments>\n"; 105 105 if (defined($options->{'args'})) { … … 125 125 126 126 # Produce the usage information using the data structure above 127 print STDERR " usage: $programname [options] collection-name\n\n"; 127 print STDERR " " . &lookup_string("{common.usage}") . ": $programname"; 128 print STDERR " " . &lookup_string("{mkcol.params}") . "\n\n"; 128 129 129 130 # Display the program options, if there are some … … 132 133 local $optiondescoffset = $descoffset + 2; # 2 spaces between options & descriptions 133 134 134 print STDERR " options:\n";135 print STDERR " " . &lookup_string("{common.options}") . ":\n"; 135 136 136 137 # Display the program options 137 138 &PrintUsage::print_options_txt($language, $programargs, $optiondescoffset); 138 139 } 140 } 141 142 143 sub lookup_string 144 { 145 return &PrintUsage::lookup_string($language, shift(@_)); 139 146 } 140 147 … … 183 190 } 184 191 185 opendir(DIR, $modeldir) || die "Can't read $modeldir"; 192 opendir(DIR, $modeldir) 193 || die &lookup_string("{common.cannot_read}") . " $modeldir"; 186 194 my @files = grep(!/^(\.\.?|CVS)$/, readdir(DIR)); 187 195 closedir(DIR); … … 198 206 $destfile =~ s/^modelcol/$collection/; 199 207 $destfile =~ s/^MODELCOL/$capcollection/; 200 print STDOUT " doing replacements for $destfile\n" unless $quiet; 208 print STDOUT " " . &lookup_string("{mkcol.doing_replacements}") . " $destfile\n" 209 unless $quiet; 201 210 $destfile = &util::filename_cat ($coldir, $destfile); 202 211 203 212 open (INFILE, $thisfile) || 204 die "ERROR: Can't read file$thisfile";213 die &lookup_string("{common.cannot_read_file}") . " $thisfile"; 205 214 open (OUTFILE, ">$destfile") || 206 die "ERROR: Can't create file$destfile";215 die &lookup_string("{common.cannot_create_file}") . " $destfile"; 207 216 208 217 while (defined ($line = <INFILE>)) { … … 256 265 257 266 if ($optionfile =~ /\w/) { 258 open (OPTIONS, $optionfile) || die "Couldn't open $optionfile\n"; 267 open (OPTIONS, $optionfile) || 268 die &lookup_string("{common.cannot_open}") . " $optionfile\n"; 259 269 my $line = []; 260 270 my $options = []; … … 266 276 } 267 277 268 # load default plugins if none were on command line 278 # load default plugins if none were on command line 269 279 if (!scalar(@plugin)) { 270 280 @plugin = (ZIPPlug,GAPlug,TEXTPlug,HTMLPlug,EMAILPlug, … … 275 285 ($collection) = @ARGV; 276 286 if (!defined($collection)) { 277 print STDOUT "ERROR: no collection name was specified\n";287 print STDOUT &lookup_string("{mkcol.no_colname}") . "\n"; 278 288 &print_txt_usage($language); 279 289 die "\n"; … … 281 291 282 292 if (length($collection) > 8) { 283 print STDOUT "ERROR: The collection name must be less than 8 characters\n"; 284 print STDOUT " so compatibility with earlier filesystems can be\n"; 285 print STDOUT " maintained.\n"; 293 print STDOUT &lookup_string("{mkcol.long_colname}") . "\n"; 286 294 die "\n"; 287 295 } 288 296 289 297 if ($collection eq "modelcol") { 290 print STDOUT "ERROR: No collection can be named modelcol as this is the\n"; 291 print STDOUT " name of the model collection.\n"; 298 print STDOUT &lookup_string("{mkcol.bad_name_modelcol}") . "\n"; 292 299 die "\n"; 293 300 } 294 301 295 302 if ($collection eq "CVS") { 296 print STDOUT "ERROR: No collection can be named CVS as this may interfere\n"; 297 print STDOUT " with directories created by the CVS versioning system\n"; 303 print STDOUT &lookup_string("{mkcol.bad_name_cvs}") . "\n"; 298 304 die "\n"; 299 305 } 300 306 301 307 if (!defined($creator) || $creator eq "") { 302 print STDOUT "ERROR: The creator was not defined. This variable is\n"; 303 print STDOUT " needed to recognise duplicate collection names.\n"; 308 print STDOUT &lookup_string("{mkcol.creator_undefined}") . "\n"; 304 309 die "\n"; 305 310 } … … 328 333 if (defined $collectdir && $collectdir =~ /\w/) { 329 334 if (!-d $collectdir) { 330 print STDOUT "ERROR: $collectdir doesn't exist\n";335 print STDOUT &lookup_string("{mkcol.no_collectdir}") . ": $collectdir\n"; 331 336 die "\n"; 332 337 } … … 337 342 338 343 # make sure the model collection exists 339 die "ERROR: Cannot find the model collection$mdir" unless (-d $mdir);344 die &lookup_string("{mkcol.cannot_find_modelcol}") . " $mdir" unless (-d $mdir); 340 345 341 346 # make sure this collection does not already exist 342 347 if (-e $cdir) { 343 print STDOUT "ERROR: This collection already exists\n";348 print STDOUT &lookup_string("{mkcol.col_already_exists}") . "\n"; 344 349 die "\n"; 345 350 } 346 351 347 352 # start creating the collection 348 print STDOUT "\nCreating the collection $collection...\n" unless $quiet; 353 print STDOUT "\n" . &lookup_string("{mkcol.creating_col}") . " $collection...\n" 354 unless $quiet; 349 355 &traverse_dir ($mdir, $cdir); 350 print STDOUT "\n The new collection was created successfully at\n" unless $quiet;351 print STDOUT "$cdir\n"unless $quiet;356 print STDOUT "\n" . &lookup_string("{mkcol.success}") . "\n$cdir\n" 357 unless $quiet; 352 358 } 353 359
Note:
See TracChangeset
for help on using the changeset viewer.