Changeset 5606


Ignore:
Timestamp:
2003-10-09T15:53:46+13:00 (21 years ago)
Author:
mdewsnip
Message:

Move some more strings out to the resource bundles (perllib/strings.rb), in preparation for translation.

Location:
trunk/gsdl/bin/script
Files:
5 edited

Legend:

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

    r5097 r5606  
    4242use util;
    4343use FileHandle;
     44use gsprintf;
    4445use printusage;
    4546
     
    185186sub lookup_string
    186187{
    187     return &PrintUsage::lookup_string($language, shift(@_));
     188    return &gsprintf::lookup_string($language, shift(@_));
    188189}
    189190
     
    533534    close CFGFILE;
    534535}
    535 
  • trunk/gsdl/bin/script/classinfo.pl

    r4873 r5606  
    3838use util;
    3939use parsargv;
     40use gsprintf;
     41use printusage;
    4042
    41 sub print_usage {
    42     print STDERR "\n";
    43     print STDERR "classinfo.pl: Prints information about a classifier.\n\n";
    44     print STDERR " usage: $0 [options] classifier\n\n";
    45     print STDERR " options:\n";
    46     print STDERR "  -collect collection-name  Giving a collection name will make classinfo.pl\n";
    47     print STDERR "                            look in collect/collection-name/perllib/classify\n";
    48     print STDERR "                            first. If the classifier is not found there it will\n";
    49     print STDERR "                            look in the general perllib/classify directory.\n\n";
    50     print STDERR "  -xml                      Produces the information in an xml form, without\n";
    51     print STDERR "                            'pretty' comments but with much more detail.\n\n";
    52     print STDERR "  -language language-code   Language to display plugin options in (eg. 'en_US'\n";
    53     print STDERR "                            specifies American English). Requires translations\n";
    54     print STDERR "                            of the option descriptions to exist in the\n";
    55     print STDERR "                            perllib/strings_language-code.rb file.\n";
     43
     44my $arguments =
     45    [ { 'name' => "collect",
     46    'desc' => "{classinfo.collect}",
     47    'type' => "string",
     48    'reqd' => "no" },
     49      { 'name' => "xml",
     50    'desc' => "{scripts.xml}",
     51    'type' => "flag",
     52    'reqd' => "no" },
     53      { 'name' => "language",
     54    'desc' => "{scripts.language}",
     55    'type' => "string",
     56    'reqd' => "no" } ];
     57
     58my $options = { 'name' => "classinfo.pl",
     59        'desc' => "{classinfo.desc}",
     60        'args' => $arguments };
     61
     62
     63sub lookup_string
     64{
     65    return &gsprintf::lookup_string($language, shift(@_));
    5666}
    5767
    58 &main ();
     68
     69sub print_txt_usage
     70{
     71    local $language = shift(@_);
     72
     73    local $programname = $options->{'name'};
     74    local $programargs = $options->{'args'};
     75
     76    # Find the length of the longest option string
     77    local $descoffset = 0;
     78    if (defined($programargs)) {
     79    $descoffset = &PrintUsage::find_longest_option_string($programargs);
     80    }
     81
     82    # Produce the usage information using the data structure above
     83    print STDERR $programname . ": " . &lookup_string($options->{'desc'}) . "\n\n";
     84    print STDERR " " . &lookup_string("{common.usage}") . ": $programname";
     85    print STDERR " " . &lookup_string("{classinfo.params}") . "\n\n";
     86
     87    # Display the program options, if there are some
     88    if (defined($programargs)) {
     89    # Calculate the column offset of the option descriptions
     90    local $optiondescoffset = $descoffset + 2;  # 2 spaces between options & descriptions
     91
     92    print STDERR " " . &lookup_string("{common.options}") . ":\n";
     93
     94    # Display the program options
     95    &PrintUsage::print_options_txt($language, $programargs, $optiondescoffset);
     96    }
     97}
     98
     99
     100#  sub print_usage {
     101#      print STDERR "\n";
     102#      print STDERR "classinfo.pl: Prints information about a classifier.\n\n";
     103#      print STDERR " usage: $0 [options] classifier\n\n";
     104#      print STDERR " options:\n";
     105#      print STDERR "  -collect collection-name  Giving a collection name will make classinfo.pl\n";
     106#      print STDERR "                            look in collect/collection-name/perllib/classify\n";
     107#      print STDERR "                            first. If the classifier is not found there it will\n";
     108#      print STDERR "                            look in the general perllib/classify directory.\n\n";
     109#      print STDERR "  -xml                      Produces the information in an xml form, without\n";
     110#      print STDERR "                            'pretty' comments but with much more detail.\n\n";
     111#      print STDERR "  -language language-code   Language to display classifer options in (eg. 'en_US'\n";
     112#      print STDERR "                            specifies American English). Requires translations\n";
     113#      print STDERR "                            of the option descriptions to exist in the\n";
     114#      print STDERR "                            perllib/strings_language-code.rb file.\n";
     115#  }
     116
    59117
    60118sub main {
     
    69127             q^language/.*/^, \$language))
    70128    {
    71     &print_usage();
     129    &print_txt_usage($language);
    72130    die "\n";
    73131    }
     
    76134    my $classifier = shift (@ARGV);
    77135    if (!defined $classifier || $classifier eq "") {
    78     print STDERR "You must provide a classifier name\n";
    79     &print_usage();
     136    print STDERR &lookup_string("{classinfo.no_classifier_name}") . "\n\n";
     137    &print_txt_usage($language);
    80138    die "\n";
    81139    }
     
    95153    }
    96154    else {
    97     print STDERR "
    98 $classifier info:
    99 
    100 Options may be passed to any classifier by including them in your collect.cfg
    101 configuration file.
    102 
    103 Classifiers may take two types of options:
    104 
    105 ";
    106     print STDERR "Specific options are defined within the classifier itself, and are available\n";
    107     print STDERR "only to this particular classifier.\n\n";
    108 
    109     print STDERR "General options are inherited from parent classes of the classifer.\n\n";
     155    print STDERR "\n$classifier " . &lookup_string("{classinfo.info}") . ":\n\n";
     156    print STDERR &lookup_string("{classinfo.passing_options}") . "\n\n";
     157    print STDERR &lookup_string("{classinfo.option_types}") . ":\n\n";
     158    print STDERR &lookup_string("{classinfo.specific_options}") . "\n\n";
     159    print STDERR &lookup_string("{classinfo.general_options}") . "\n\n";
    110160
    111161    $classobj->print_txt_usage($language);
     
    114164
    115165
    116 
    117 
     166&main ();
  • trunk/gsdl/bin/script/import.pl

    r5097 r5606  
    4646use parsargv;
    4747use FileHandle;
     48use gsprintf;
    4849use printusage;
    4950
     
    183184sub lookup_string
    184185{
    185     return &PrintUsage::lookup_string($language, shift(@_));
     186    return &gsprintf::lookup_string($language, shift(@_));
    186187}
    187188
  • trunk/gsdl/bin/script/mkcol.pl

    r5092 r5606  
    4242use util;
    4343use cfgread;
     44use gsprintf;
    4445use printusage;
    4546
     
    143144sub lookup_string
    144145{
    145     return &PrintUsage::lookup_string($language, shift(@_));
     146    return &gsprintf::lookup_string($language, shift(@_));
    146147}
    147148
  • trunk/gsdl/bin/script/pluginfo.pl

    r4873 r5606  
    4040use util;
    4141use parsargv;
     42use gsprintf;
     43use printusage;
    4244
    43 sub print_usage {
    44     print STDERR "\n";
    45     print STDERR "pluginfo.pl: Prints information about a plugin.\n\n";
    46     print STDERR " usage: $0 [options] plugin\n\n";
    47     print STDERR " options:\n";
    48     print STDERR "  -collect collection-name  Giving a collection name will make pluginfo.pl\n";
    49     print STDERR "                            look in collect/collection-name/perllib/plugins\n";
    50     print STDERR "                            first. If the plugin is not found there it will\n";
    51     print STDERR "                            look in the general perllib/plugins directory.\n\n";
    52     print STDERR "  -xml                      Produces the information in an xml form, without\n";
    53     print STDERR "                            'pretty' comments but with much more detail.\n\n";
    54     print STDERR "  -language language-code   Language to display plugin options in (eg. 'en_US'\n";
    55     print STDERR "                            specifies American English). Requires translations\n";
    56     print STDERR "                            of the option descriptions to exist in the\n";
    57     print STDERR "                            perllib/strings_language-code.rb file.\n";
     45
     46my $arguments =
     47    [ { 'name' => "collect",
     48    'desc' => "{pluginfo.collect}",
     49    'type' => "string",
     50    'reqd' => "no" },
     51      { 'name' => "xml",
     52    'desc' => "{scripts.xml}",
     53    'type' => "flag",
     54    'reqd' => "no" },
     55      { 'name' => "language",
     56    'desc' => "{scripts.language}",
     57    'type' => "string",
     58    'reqd' => "no" } ];
     59
     60my $options = { 'name' => "pluginfo.pl",
     61        'desc' => "{pluginfo.desc}",
     62        'args' => $arguments };
     63
     64
     65sub lookup_string
     66{
     67    return &gsprintf::lookup_string($language, shift(@_));
    5868}
    5969
    6070
    61 &main ();
     71sub print_txt_usage
     72{
     73    local $language = shift(@_);
     74
     75    local $programname = $options->{'name'};
     76    local $programargs = $options->{'args'};
     77
     78    # Find the length of the longest option string
     79    local $descoffset = 0;
     80    if (defined($programargs)) {
     81    $descoffset = &PrintUsage::find_longest_option_string($programargs);
     82    }
     83
     84    # Produce the usage information using the data structure above
     85    print STDERR $programname . ": " . &lookup_string($options->{'desc'}) . "\n\n";
     86    print STDERR " " . &lookup_string("{common.usage}") . ": $programname";
     87    print STDERR " " . &lookup_string("{pluginfo.params}") . "\n\n";
     88
     89    # Display the program options, if there are some
     90    if (defined($programargs)) {
     91    # Calculate the column offset of the option descriptions
     92    local $optiondescoffset = $descoffset + 2;  # 2 spaces between options & descriptions
     93
     94    print STDERR " " . &lookup_string("{common.options}") . ":\n";
     95
     96    # Display the program options
     97    &PrintUsage::print_options_txt($language, $programargs, $optiondescoffset);
     98    }
     99}
     100
     101
     102#  sub print_usage {
     103#      print STDERR "\n";
     104#      print STDERR "pluginfo.pl: Prints information about a plugin.\n\n";
     105#      print STDERR " usage: $0 [options] plugin\n\n";
     106#      print STDERR " options:\n";
     107#      print STDERR "  -collect collection-name  Giving a collection name will make pluginfo.pl\n";
     108#      print STDERR "                            look in collect/collection-name/perllib/plugins\n";
     109#      print STDERR "                            first. If the plugin is not found there it will\n";
     110#      print STDERR "                            look in the general perllib/plugins directory.\n\n";
     111#      print STDERR "  -xml                      Produces the information in an xml form, without\n";
     112#      print STDERR "                            'pretty' comments but with much more detail.\n\n";
     113#      print STDERR "  -language language-code   Language to display plugin options in (eg. 'en_US'\n";
     114#      print STDERR "                            specifies American English). Requires translations\n";
     115#      print STDERR "                            of the option descriptions to exist in the\n";
     116#      print STDERR "                            perllib/strings_language-code.rb file.\n";
     117#  }
    62118
    63119sub main {
     
    71127             q^language/.*/^, \$language))
    72128    {
    73     &print_usage();
     129    &print_txt_usage($language);
    74130    die "\n";
    75131    }
     
    77133    my $plugin = shift (@ARGV);
    78134    if (!defined $plugin || $plugin eq "") {
    79     print STDERR "You must provide a plugin name\n";
    80     &print_usage();
     135    print STDERR &lookup_string("{pluginfo.no_plugin_name}") . "\n\n";
     136    &print_txt_usage($language);
    81137    die "\n";
    82138    }
     
    95151    }
    96152    else {
    97     print STDERR "\n$plugin info:\n\n";
    98 
    99     print STDERR "Options may be passed to any plugin by including them in your collect.cfg\n";
    100     print STDERR "configuration file.\n\n";
    101 
    102     print STDERR "Plugins may take two types of options:\n\n";
    103 
    104     print STDERR "Specific options are defined within the plugin itself, and are available\n";
    105     print STDERR "only to this particular plugin.\n\n";
    106 
    107     print STDERR "General options are inherited from parent classes of the plugin.\n\n";
     153    print STDERR "\n$plugin " . &lookup_string("{pluginfo.info}") . ":\n\n";
     154    print STDERR &lookup_string("{pluginfo.passing_options}") . "\n\n";
     155    print STDERR &lookup_string("{pluginfo.option_types}") . ":\n\n";
     156    print STDERR &lookup_string("{pluginfo.specific_options}") . "\n\n";
     157    print STDERR &lookup_string("{pluginfo.general_options}") . "\n\n";
    108158
    109159    $plugobj->print_txt_usage($language);
     
    117167}
    118168
     169
     170&main ();
Note: See TracChangeset for help on using the changeset viewer.