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

Diff of /bibulus/Bibulus/language.pm

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

revision 1.2 by twid, Mon Jul 21 09:49:10 2003 UTC revision 1.3 by twid, Mon Jul 21 12:52:42 2003 UTC
# Line 3  package Bibulus; Line 3  package Bibulus;
3  # This file is part of Bibulus.  # This file is part of Bibulus.
4  # For copyright and license, please refer to ../Bibulus.pm  # For copyright and license, please refer to ../Bibulus.pm
5    
6    # This files contains various functions to deal with languages.
7    
8  sub setmainlang {  sub setmainlang {
9    my $self = shift;    my $self = shift;
10    my $lang = shift;    my $lang = shift;
# Line 10  sub setmainlang { Line 12  sub setmainlang {
12    $self->{MAINLANG} = $lang;    $self->{MAINLANG} = $lang;
13  }  }
14    
15  # Language files are read for each object so that individual fields  # A function to get and set languages.  Originally, it verified the
16  # can be easily overridden.  # language, but that will make it difficult for users to add more
17  sub initlang {  # languages.  Perhaps one should strip off _XX (country codes)?
   my $self = shift;  
 #  do 'lang.pl';  # auto-generated from lang/*.dat  
 }  
   
   
 # Language stuff  
18  sub lang {  sub lang {
19    my $self = shift;    my $self = shift;
20    
21    if (@_) {    if (@_) {
22      my $l = shift;      my $l = shift;
23      if ($l =~ /^(en|da)$/) {    # accepted languages      $self->{LANG} = $l;
       $self->{LANG} = $l;  
     } else {  
       warn "Language $l unknown.\n";  
     }  
24    }    }
25    
26    return $self->{LANG};    return $self->{LANG};
27  }  }
28    
# Line 42  sub AUTOLOAD { Line 36  sub AUTOLOAD {
36    my ($self) = @_;    my ($self) = @_;
37    my ($pkg, $meth) = $AUTOLOAD =~ /(.*)::(.*)/;    my ($pkg, $meth) = $AUTOLOAD =~ /(.*)::(.*)/;
38    $meth =~ /DESTROY/ and return;    $meth =~ /DESTROY/ and return;
39      my $m;
40    
41      # Get into the right namespace:
42    eval "require Bibulus::$self->{LANG}" or die $@;    eval "require Bibulus::$self->{LANG}" or die $@;
43    $meth = "Bibulus::$self->{LANG}::$meth";  
44    goto &$meth;    # Load some text strings into $self if they're not there already:
45      $meth ne 'populate' and !defined($self->{LANGINIT}{$self->{LANG}})
46        and $self->populate;
47      $m = "Bibulus::$self->{LANG}::$meth";
48    
49      # Now go to the function if it's there
50      defined(&$m) and goto &$m;
51    
52      # If it's not, look for it in general.pm:
53      eval "require Bibulus::general" or die $@;
54      $m = "Bibulus::general::$meth";
55      defined(&$m) and goto &$m;
56    
57      # Otherwise, die!
58      die "$m not found in $self->{LANG} or general.\n";
59  }  }
60    
61  1;  1;

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