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

Tidied up gsprintf code in preparation for adding the French/Spanish/Russian translations.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/gsprintf.pm

    r5613 r6920  
    3939
    4040    # Look up all the strings in the dictionary
    41     $text_string =~ s/(\{[^\}]+\})/&new_lookup_string($1)/eg;
     41    $text_string =~ s/(\{[^\}]+\})/&lookup_string("", $1)/eg;
    4242
    4343    # Resolve the string arguments using sprintf, then write out to the handle
     
    4646
    4747
    48 sub new_lookup_string
     48sub lookup_string
    4949{
    50     local ($stringkey) = @_;
     50    local ($language, $stringkey) = @_;
    5151
    5252    # Load the default resource bundle
    53     local %resourcebundle = &load_resource_bundle("");
     53    local %resourcebundle = &load_resource_bundle($language);
    5454
    5555    # Return the text matching the key (or just the key, if no match was found)
     
    109109
    110110
    111 #  sub gsprintf
    112 #  {
    113 #      my ($handle, $verbosity_threshold, $text_string, @text_arguments) = @_;
    114 
    115 #      # Return unless the required arguments were supplied
    116 #      return unless (defined($handle) && defined($verbosity_threshold) && defined($text_string));
    117 
    118 #      # Return if the verbosity threshold isn't met
    119 #      return if (defined($verbosity) && $verbosity < $verbosity_threshold);
    120 
    121 #      # Look up all the strings in the dictionary
    122 #      $text_string =~ s/(\{[^\}]+\})/&new_lookup_string($1)/eg;
    123 
    124 #      # Resolve the string arguments using sprintf, then write out to the handle
    125 #      print $handle sprintf($text_string, @text_arguments);
    126 #  }
    127 
    128 
    129 sub lookup_string
    130 {
    131     local ($language, $stringkey) = @_;
    132 
    133     $language = "" if !defined($language);
    134 
    135     # Load the appropriate resource bundle
    136     local %resourcebundle = &load_resource_bundle($language);
    137 
    138     # Return the text matching the key (or just the key, if no match was found)
    139     return $resourcebundle{$stringkey} || $stringkey;
    140 }
    141 
    142 
    1431111;
    144 
    145 
Note: See TracChangeset for help on using the changeset viewer.