/[bibulus]/bibulus/Bibulus/general.pm
ViewVC logotype

Diff of /bibulus/Bibulus/general.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by twid, Mon Jul 21 12:52:42 2003 UTC revision 1.3 by twid, Sun Sep 14 11:52:37 2003 UTC
# Line 10  sub populate { Line 10  sub populate {
10    $self->{LANGTEXT}{general}{and} ||= '[default:and]';    $self->{LANGTEXT}{general}{and} ||= '[default:and]';
11    $self->{LANGTEXT}{general}{comma} ||= ', ';    $self->{LANGTEXT}{general}{comma} ||= ', ';
12    $self->{LANGTEXT}{general}{fullstop} ||= '. ';    $self->{LANGTEXT}{general}{fullstop} ||= '. ';
13      $self->{LANGTEXT}{general}{abbrsign} ||= '.' . $self->nobreakspace;
14    $self->{LANGTEXT}{general}{in} ||= '[default:in]';    $self->{LANGTEXT}{general}{in} ||= '[default:in]';
15    $self->{LANGTEXT}{general}{edition} ||= '[default:edition]';    $self->{LANGTEXT}{general}{edition} ||= '[default:edition]';
16    $self->{LANGTEXT}{general}{technicalreport} ||= '[default:technicalreport]';    $self->{LANGTEXT}{general}{technicalreport} ||= '[default:technicalreport]';
# Line 23  sub populate { Line 24  sub populate {
24    $self->{LANGINIT}{general} = 1;    $self->{LANGINIT}{general} = 1;
25  }  }
26    
27  sub and {  # Take a list of names and return them separated with commas or ands
28    my $self = shift;  # or whatever is used in this language.
29    return $self->{LANGTEXT}{$self->{LANG}}{and};  # The default will return "X", "X and Y", "X, Y and Z", "X, Y, Z and U".
30    sub andlist {
31      my $self = shift;
32      my @names = @_;
33    
34      my $r = '';
35    
36      foreach my $i (0 .. $#names) {
37        $r .= $names[$i];
38    
39        if ($i < $#names - 1) {
40          $r .= $self->comma;
41        } elsif ($i == $#names - 1) {
42          $r .= " $self->{LANGTEXT}{$self->{LANG}}{and} ";
43        }
44      }
45    
46      return $r;
47  }  }
48    
49    # Return a comma (followed by a space if necessary).
50  sub comma {  sub comma {
51    my $self = shift;    my $self = shift;
52    return $self->{LANGTEXT}{$self->{LANG}}{comma};    return $self->{LANGTEXT}{$self->{LANG}}{comma};
53  }  }
54    
55    # Return a full stop (followed by a space if necessary).
56  sub fullstop {  sub fullstop {
57    my $self = shift;    my $self = shift;
58    return $self->{LANGTEXT}{$self->{LANG}}{fullstop};    return $self->{LANGTEXT}{$self->{LANG}}{fullstop};
59  }  }
60    
61    # Return an abbreviation sign (followed by a space or a non-breakable
62    # one if necessary).
63    # This is the function to use for abbreviating names of people and months.
64    sub abbrsign {
65      my $self = shift;
66      return $self->{LANGTEXT}{$self->{LANG}}{abbrsign};
67    }
68    
69    # Take a text $t and return "in $t".  $t is typically a reference to
70    # another entry.
71  sub in {  sub in {
72    my $self = shift;    my $self = shift;
73    my $t = shift;    my $t = shift;
74    return $self->{LANGTEXT}{$self->{LANG}}{in} . $self->nobreakspace . $t;    return $self->{LANGTEXT}{$self->{LANG}}{in} . $self->nobreakspace . $t;
75  }  }
76    
77    # Take an edition number and return "fifth edition" of "5th ed." or
78    # whatever is needed.  Abbreviation of "edition" is governed by
79    # $self->{STYLE}{abbredition}.
80    # Don't abbreviate if it's not relevant in a given language!
81  sub edition {  sub edition {
82    my $self = shift;    my $self = shift;
83    my $num = shift;    my $num = shift;
84    return $self->ordinal($num) . ' '  
85      . $self->{LANGTEXT}{$self->{LANG}}{edition};    my $l = $self->{LANG}; # current language
86      my $edword;
87      if ($self->{STYLE}{abbredition}
88          and defined($self->{LANGTEXT}{$l}{edition}{abbr})) {
89        $edword = $self->{LANGTEXT}{$l}{edition}{abbr};
90      } elsif (!$self->{STYLE}{abbredition}
91          and defined($self->{LANGTEXT}{$l}{edition}{full})) {
92        $edword = $self->{LANGTEXT}{$l}{edition}{full};
93      } else {
94        $edword = $self->{LANGTEXT}{$l}{edition};
95      }
96    
97      return $self->ordinal($num) . ' '  # should this be $self->nobreakspace?
98        . $edword;
99  }  }
100    
101    
102    # Either return "Technical Report" or "Technical Report #$number",
103    # depending on whether $num is given or not.  Abbreviate if necessary.
104  sub technicalreport {  sub technicalreport {
105    my $self = shift;    my $self = shift;
106    my $num = shift;    my $num = shift;
107    my $t = $self->{LANGTEXT}{$self->{LANG}}{technicalreport};  
108      my $l = $self->{LANG}; # current language
109    
110      my $tr;
111      if ($self->{STYLE}{abbrwords}
112          and defined($self->{LANGTEXT}{$l}{technicalreport}{abbr})) {
113        $tr = $self->{LANGTEXT}{$l}{technicalreport}{abbr};
114      } elsif (!$self->{STYLE}{abbrwords}
115          and defined($self->{LANGTEXT}{$l}{technicalreport}{full})) {
116        $tr = $self->{LANGTEXT}{$l}{technicalreport}{full};
117      } else {
118        $tr = $self->{LANGTEXT}{$l}{technicalreport};
119      }
120    
121    if ($num) {    if ($num) {
122      $t .= ' ' . $self->{LANGTEXT}{$self->{LANG}}{numberabbr}      $tr .= $self->nobreakspace . $num;
       . $self->nobreakspace . $num;  
123    }    }
124    return $t;  
125      return $tr;
126  }  }
127    
128  sub chapter {  sub chapter {
# Line 104  sub numberseries { Line 167  sub numberseries {
167    return $t;    return $t;
168  }  }
169    
170    # Return the ordinal number of number $number
171    # (e.g., 5 -> "fifth" or "5th").
172    # Abbreviation depends of $self->{STYLE}{abbrordinals}.
173  sub ordinal {  sub ordinal {
174    my $self = shift;    my $self = shift;
175    my ($number) = @_;    my ($number) = @_;
176    
177    return "[general:ordinal:$number]";    if ($self->{STYLE}{abbrordinals}) {
178        if (defined($self->{LANGTEXT}{$self->{LANG}}{ordinal}{$number}{abbr})) {
179          return $self->{LANGTEXT}{$self->{LANG}}{ordinal}{$number}{abbr};
180        } else {
181          return $number . $self->{LANGTEXT}{$self->{LANG}}{th};
182        }
183      } else { # not abbreviated
184        if (defined($self->{LANGTEXT}{$self->{LANG}}{ordinal}{$number}{full})) {
185          return $self->{LANGTEXT}{$self->{LANG}}{ordinal}{$number}{full};
186        } elsif (defined($self->{LANGTEXT}{$self->{LANG}}{ordinal}{$number})) {
187          return $self->{LANGTEXT}{$self->{LANG}}{ordinal}{$number};
188        } else {
189          return $number . $self->{LANGTEXT}{$self->{LANG}}{th};
190        }
191      }
192  }  }
193    
194    

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26