Changeset 5092


Ignore:
Timestamp:
2003-08-04T16:11:57+12:00 (21 years ago)
Author:
mdewsnip
Message:

Moved all output messages into the resource bundle (perllib/strings.rb), in preparation for translation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/bin/script/mkcol.pl

    r4873 r5092  
    8989
    9090my $options = { 'name' => "mkcol.pl",
    91         'desc' => "PERL script used to create the directory structure for a new Greenstone collection.",
     91        'desc' => "{mkcol.desc}",
    9292        'args' => $arguments };
    9393
     
    101101    print STDERR "<Info>\n";
    102102    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";
    104104    print STDERR "  <Arguments>\n";
    105105    if (defined($options->{'args'})) {
     
    125125
    126126    # 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";
    128129
    129130    # Display the program options, if there are some
     
    132133    local $optiondescoffset = $descoffset + 2;  # 2 spaces between options & descriptions
    133134
    134     print STDERR " options:\n";
     135    print STDERR " " . &lookup_string("{common.options}") . ":\n";
    135136
    136137    # Display the program options
    137138    &PrintUsage::print_options_txt($language, $programargs, $optiondescoffset);
    138139    }
     140}
     141
     142
     143sub lookup_string
     144{
     145    return &PrintUsage::lookup_string($language, shift(@_));
    139146}
    140147
     
    183190    }
    184191
    185     opendir(DIR, $modeldir) || die "Can't read $modeldir";
     192    opendir(DIR, $modeldir)
     193    || die &lookup_string("{common.cannot_read}") . " $modeldir";
    186194    my @files = grep(!/^(\.\.?|CVS)$/, readdir(DIR));
    187195    closedir(DIR);
     
    198206        $destfile =~ s/^modelcol/$collection/;
    199207        $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;
    201210        $destfile = &util::filename_cat ($coldir, $destfile);
    202        
     211
    203212        open (INFILE, $thisfile) ||
    204         die "ERROR: Can't read file $thisfile";
     213        die &lookup_string("{common.cannot_read_file}") . " $thisfile";
    205214        open (OUTFILE, ">$destfile") ||
    206         die "ERROR: Can't create file $destfile";
     215        die &lookup_string("{common.cannot_create_file}") . " $destfile";
    207216
    208217        while (defined ($line = <INFILE>)) {
     
    256265
    257266    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";
    259269    my $line = [];
    260270    my $options = [];
     
    266276    }
    267277
    268     # load default plugins if none were on command line   
     278    # load default plugins if none were on command line
    269279    if (!scalar(@plugin)) {
    270280    @plugin = (ZIPPlug,GAPlug,TEXTPlug,HTMLPlug,EMAILPlug,
     
    275285    ($collection) = @ARGV;
    276286    if (!defined($collection)) {
    277     print STDOUT "ERROR: no collection name was specified\n";
     287    print STDOUT &lookup_string("{mkcol.no_colname}") . "\n";
    278288    &print_txt_usage($language);
    279289    die "\n";
     
    281291
    282292    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";
    286294    die "\n";
    287295    }
    288296
    289297    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";
    292299    die "\n";
    293300    }
    294301
    295302    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";
    298304    die "\n";
    299305    }
    300306
    301307    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";
    304309    die "\n";
    305310    }
     
    328333    if (defined $collectdir && $collectdir =~ /\w/) {
    329334    if (!-d $collectdir) {
    330         print STDOUT "ERROR: $collectdir doesn't exist\n";
     335        print STDOUT &lookup_string("{mkcol.no_collectdir}") . ": $collectdir\n";
    331336        die "\n";
    332337    }
     
    337342
    338343    # 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);
    340345
    341346    # make sure this collection does not already exist
    342347    if (-e $cdir) {
    343     print STDOUT "ERROR: This collection already exists\n";
     348    print STDOUT &lookup_string("{mkcol.col_already_exists}") . "\n";
    344349    die "\n";
    345350    }
    346351
    347352    # 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;
    349355    &traverse_dir ($mdir, $cdir);
    350     print STDOUT "\nThe 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;
    352358}
    353359
Note: See TracChangeset for help on using the changeset viewer.