X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXM.pm;h=5a3b22e3b086415804cde6ab1c317e9fae16bed8;hb=a0cf638d2ec10e9f464bb749cf1b70fd105baf9f;hp=64602a2683b48bb634dd79078bc328e5b6257b9a;hpb=1d5894e63b48f6996ef75654faf0806d69c7b502;p=spider.git diff --git a/perl/DXM.pm b/perl/DXM.pm index 64602a26..5a3b22e3 100644 --- a/perl/DXM.pm +++ b/perl/DXM.pm @@ -17,46 +17,39 @@ package DXM; use DXVars; +use Carp; -%msgs = ( - addr => 'Address set to: $_[0]', - anns => 'Announce flag set on $_[0]', - annu => 'Announce flag unset on $_[0]', - conother => 'Sorry $_[0] you are connected on another port', - concluster => 'Sorry $_[0] you are already connected elsewhere on the cluster', - dxs => 'DX Spots flag set on $_[0]', - dxu => 'DX Spots flag unset on $_[0]', - e1 => 'Invalid command', - e2 => 'Error: $_[0]', - e3 => '$_[0]: $_[1] not found', - e4 => 'Need at least a prefix or callsign', - e5 => 'Not Allowed', - email => 'E-mail address set to: $_[0]', - heres => 'Here set on $_[0]', - hereu => 'Here unset on $_[0]', - homebbs => 'Home BBS set to: $_[0]', - homenode => 'Home Node set to: $_[0]', - l1 => 'Sorry $_[0], you are already logged on on another channel', - l2 => 'Hello $_[0], this is $main::mycall located in $main::myqth', - m2 => '$_[0] Information: $_[1]', - node => '$_[0] set as AK1A style Node', - nodee1 => 'You cannot use this command whilst your target ($_[0]) is on-line', - pr => '$_[0] de $main::mycall $main::cldate $main::ztime >', - priv => 'Privilege level changed on $_[0]', - prx => '$main::$mycall >', - talks => 'Talk flag set on $_[0]', - talku => 'Talk flag unset on $_[0]', - wwvs => 'WWV flag set on $_[0]', - wwvu => 'WWV flag unset on $_[0]', -); +my $localfn = "$main::root/local/Messages"; +my $fn = "$main::root/perl/Messages"; sub msg { - my $self = shift; - my $s = $msgs{$self}; - return "unknown message '$self'" if !defined $s; - my $ans = eval qq{ "$s" }; - confess $@ if $@; - return $ans; + my $lang = shift; + my $m = shift; + my $ref = $msgs{$lang}; + my $s = $ref->{$m} if $ref; + return "unknown message '$m' in lang '$lang'" if !defined $s; + my $ans = eval qq{ "$s" }; + confess $@ if $@; + return $ans; +} + +sub load +{ + my $ref = shift; + if (-e $localfn) { + do $localfn; + return ($@) if $@ && ref $ref; + confess $@ if $@; + return (); + } + do $fn; + return ($@) if $@ && ref $ref; + confess $@ if $@; + return (); +} + +sub init +{ + load(); } -