added the hooks for internationalisation
[spider.git] / perl / DXM.pm
1 #
2 # DX cluster message strings for output
3 #
4 # Each message string will substitute $_[x] positionally. What this means is
5 # that if you don't like the order in which fields in each message is output then 
6 # you can change it. Also you can include various globally accessible variables
7 # in the string if you want. 
8 #
9 # Largely because I don't particularly want to have to change all these messages
10 # in every upgrade I shall attempt to add new field to the END of the list :-)
11 #
12 # Copyright (c) 1998 - Dirk Koopman G1TLH
13 #
14 # $Id$
15 #
16
17 package DXM;
18
19 use DXVars;
20 use Carp;
21
22 my $localfn = "$main::root/local/Messages";
23 my $fn = "$main::root/perl/Messages";
24
25 sub msg
26 {
27         my $lang = shift;
28         my $m = shift;
29         my $ref = $msgs{$lang};
30         my $s = $ref->{$m} if $ref;
31         return "unknown message '$m' in lang '$lang'" if !defined $s;
32         my $ans = eval qq{ "$s" };
33         confess $@ if $@;
34         return $ans;
35 }
36
37 sub load
38 {
39         my $ref = shift;
40         if (-e $localfn) {
41                 do $localfn;
42                 return ($@) if $@ && ref $ref;
43                 confess $@ if $@;
44                 return ();
45         }
46         do $fn;
47         return ($@) if $@ && ref $ref;
48         confess $@ if $@;
49         return ();
50 }
51
52 sub init
53 {
54         load();
55 }