Changeset 6925


Ignore:
Timestamp:
2004-03-04T16:37:57+13:00 (20 years ago)
Author:
mdewsnip
Message:

Changed the way display in different languages is done. Instead of passing a language variable throughout the process, the desired resource bundle is explicitly loaded during the initialization of each program (buildcol.pl, classinfo.pl, exportcol.pl, import.pl mkcol.pl, pluginfo.pl).

Location:
trunk/gsdl/perllib
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/classify/BasClas.pm

    r6918 r6925  
    9393{
    9494    local $self = shift(@_);
    95     local $language = shift(@_);
    9695
    9796    &PrintUsage::print_xml_header();
    98     $self->print_xml($language);
     97    $self->print_xml();
    9998}
    10099
     
    103102{
    104103    local $self = shift(@_);
    105     local $language = shift(@_);
    106104
    107105    local $optionlistref = $self->{'option_list'};
     
    117115    print STDERR "  <Arguments>\n";
    118116    if (defined($classifieroptions->{'args'})) {
    119     &PrintUsage::print_options_xml($language, $classifieroptions->{'args'});
     117    &PrintUsage::print_options_xml($classifieroptions->{'args'});
    120118    }
    121119
    122120    # Recurse up the classifier hierarchy
    123     $self->print_xml($language);
     121    $self->print_xml();
    124122
    125123    print STDERR "  </Arguments>\n";
     
    131129{
    132130    local $self = shift(@_);
    133     local $language = shift(@_);
    134131
    135132    # Print the usage message for a classifier (recursively)
    136133    local $descoffset = $self->determine_description_offset(0);
    137     $self->print_classifier_usage($language, $descoffset, 1);
     134    $self->print_classifier_usage($descoffset, 1);
    138135}
    139136
     
    168165{
    169166    local $self = shift(@_);
    170     local $language = shift(@_);
    171167    local $descoffset = shift(@_);
    172168    local $isleafclass = shift(@_);
     
    198194
    199195    # Display the classifier options
    200     &PrintUsage::print_options_txt($language, $classifierargs, $optiondescoffset);
     196    &PrintUsage::print_options_txt($classifierargs, $optiondescoffset);
    201197    }
    202198
    203199    # Recurse up the classifier hierarchy
    204     $self->print_classifier_usage($language, $descoffset, 0);
     200    $self->print_classifier_usage($descoffset, 0);
    205201    $self->{'option_list'} = \@optionlist;
    206202}
  • trunk/gsdl/perllib/gsprintf.pm

    r6920 r6925  
    3131
    3232
     33my $loadedlanguage = "<none>";
     34my %loadedresourcebundle = ();
     35
     36
    3337sub gsprintf
    3438{
     
    3943
    4044    # Look up all the strings in the dictionary
    41     $text_string =~ s/(\{[^\}]+\})/&lookup_string("", $1)/eg;
     45    $text_string =~ s/(\{[^\}]+\})/&lookup_string($1)/eg;
    4246
    4347    # Resolve the string arguments using sprintf, then write out to the handle
     
    4852sub lookup_string
    4953{
    50     local ($language, $stringkey) = @_;
     54    local ($stringkey) = @_;
    5155
    52     # Load the default resource bundle
    53     local %resourcebundle = &load_resource_bundle($language);
     56    # Load the default resource bundle if one isn't already loaded
     57    if ($loadedlanguage eq "<none>") {
     58    &load_resource_bundle("");
     59    }
    5460
    5561    # Return the text matching the key (or just the key, if no match was found)
    56     return $resourcebundle{$stringkey} || $stringkey;
     62    return $loadedresourcebundle{$stringkey} || $stringkey;
    5763}
    5864
    59 
    60 my $cachedlanguage = "<none>";
    61 my %cachedresourcebundle = ();
    6265
    6366sub load_resource_bundle
     
    6568    local $language = shift(@_);
    6669
    67     # If the desired resource bundle is the one cached, return it
    68     if ($language eq $cachedlanguage) {
    69     return %cachedresourcebundle;
     70    # If the desired resource bundle is the one already loaded, no action is necessary
     71    if ($language eq $loadedlanguage) {
     72    return;
    7073    }
    7174
     
    8689    close(RESOURCE_BUNDLE);
    8790
    88     # Load and cache this resource bundle
    89     $cachedlanguage = $language;
    90     %cachedresourcebundle = ();
     91    # Load this resource bundle
     92    $loadedlanguage = $language;
     93    %loadedresourcebundle = ();
    9194    foreach $line (@resourcebundlelines) {
    9295    # Remove any trailing whitespace
     
    101104
    102105        # Map key to text
    103         $cachedresourcebundle{$linekey} = $linetext;
     106        $loadedresourcebundle{$linekey} = $linetext;
    104107    }
    105108    }
    106 
    107     return %cachedresourcebundle;
    108109}
    109110
  • trunk/gsdl/perllib/plugins/BasPlug.pm

    r6918 r6925  
    155155{
    156156    local $self = shift(@_);
    157     local $language = shift(@_);
    158157
    159158    &PrintUsage::print_xml_header();
    160     $self->print_xml($language);
     159    $self->print_xml();
    161160}
    162161
     
    165164{
    166165    local $self = shift(@_);
    167     local $language = shift(@_);
    168166
    169167    local $optionlistref = $self->{'option_list'};
     
    179177    print STDERR "  <Arguments>\n";
    180178    if (defined($pluginoptions->{'args'})) {
    181     &PrintUsage::print_options_xml($language, $pluginoptions->{'args'});
     179    &PrintUsage::print_options_xml($pluginoptions->{'args'});
    182180    }
    183181
    184182    # Recurse up the plugin hierarchy
    185     $self->print_xml($language);
     183    $self->print_xml();
    186184
    187185    print STDERR "  </Arguments>\n";
     
    193191{
    194192    local $self = shift(@_);
    195     local $language = shift(@_);
    196193
    197194    # Print the usage message for a plugin (recursively)
    198195    local $descoffset = $self->determine_description_offset(0);
    199     $self->print_plugin_usage($language, $descoffset, 1);
     196    $self->print_plugin_usage($descoffset, 1);
    200197}
    201198
     
    230227{
    231228    local $self = shift(@_);
    232     local $language = shift(@_);
    233229    local $descoffset = shift(@_);
    234230    local $isleafclass = shift(@_);
     
    260256
    261257    # Display the plugin options
    262     &PrintUsage::print_options_txt($language, $pluginargs, $optiondescoffset);
     258    &PrintUsage::print_options_txt($pluginargs, $optiondescoffset);
    263259    }
    264260
    265261    # Recurse up the plugin hierarchy
    266     $self->print_plugin_usage($language, $descoffset, 0);
     262    $self->print_plugin_usage($descoffset, 0);
    267263    $self->{'option_list'} = \@optionlist;
    268264}
  • trunk/gsdl/perllib/printusage.pm

    r6920 r6925  
    3939sub print_xml_usage
    4040{
    41     my $language = shift(@_);
    4241    my $options = shift(@_);
    4342
     
    4948    &gsprintf(STDERR, "  <Arguments>\n");
    5049    if (defined($options->{'args'})) {
    51     &print_options_xml($language, $options->{'args'});
     50    &print_options_xml($options->{'args'});
    5251    }
    5352    &gsprintf(STDERR, "  </Arguments>\n");
     
    7877sub print_options_xml
    7978{
    80     my $language = shift(@_);
    8179    my $options = shift(@_);
    8280
    8381    foreach $option (@$options) {
    8482    my $optionname = $option->{'name'};
    85     my $optiondesc = &gsprintf::lookup_string($language, $option->{'desc'});
     83    my $optiondesc = &gsprintf::lookup_string($option->{'desc'});
    8684
    8785    # Escape '<' and '>' characters
     
    113111        &gsprintf(STDERR, "          <Name>$optionvalue->{'name'}</Name>\n");
    114112        if (defined $optionvalue->{'desc'}) {
    115             my $optionvaluedesc = &gsprintf::lookup_string($language, $optionvalue->{'desc'});
     113            my $optionvaluedesc = &gsprintf::lookup_string($optionvalue->{'desc'});
    116114
    117115            # Escape '<' and '>' characters
     
    165163sub print_txt_usage
    166164{
    167     my $language = shift(@_);
    168165    my $options = shift(@_);
    169166    my $params = shift(@_);
     
    193190
    194191    # Display the program options
    195     &print_options_txt($language, $programargs, $optiondescoffset);
     192    &print_options_txt($programargs, $optiondescoffset);
    196193    }
    197194}
     
    200197sub print_options_txt
    201198{
    202     my $language = shift(@_);
    203199    my $options = shift(@_);
    204200    my $optiondescoffset = shift(@_);
     
    218214
    219215    # Display the option description
    220     my $optiondesc = &gsprintf::lookup_string($language, $option->{'desc'});
     216    my $optiondesc = &gsprintf::lookup_string($option->{'desc'});
    221217    my $optionreqd = $option->{'reqd'};
    222218    if (defined($optionreqd) && $optionreqd eq "yes") {
    223         $optiondesc = "(" . &gsprintf::lookup_string($language, "{PrintUsage.required}") . ") " . $optiondesc;
     219        $optiondesc = "(" . &gsprintf::lookup_string("{PrintUsage.required}") . ") " . $optiondesc;
    224220    }
    225221    &display_text_in_column($optiondesc, $optiondescoffset, $optionstringlength, 80);
     
    241237        &gsprintf(STDERR, "$optionvaluename:");
    242238
    243         my $optionvaluedesc = &gsprintf::lookup_string($language, $optionvalue->{'desc'});
     239        my $optionvaluedesc = &gsprintf::lookup_string($optionvalue->{'desc'});
    244240        &display_text_in_column($optionvaluedesc, $optiondescoffset + 2,
    245241                    $optiondescoffset + length($optionvaluename), 80);
Note: See TracChangeset for help on using the changeset viewer.