* Add enclair_db option to UserDB.pm. Allows logging of enclair password
[interchange.git] / code / SystemTag / msg.coretag
1 # Copyright 2002-2007 Interchange Development Group and others
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.  See the LICENSE file for details.
7
8 # $Id: msg.coretag,v 1.4 2007-03-30 23:40:49 pajamian Exp $
9
10 UserTag msg                 Order        key
11 UserTag msg                 addAttr
12 UserTag msg                 attrAlias    lc inline
13 UserTag msg                 hasEndTag
14 UserTag msg                 Interpolate
15 UserTag msg                 PosNumber    1
16 UserTag msg                 Version      $Revision: 1.4 $
17 UserTag msg                 Routine      <<EOR
18 sub {
19         my ($key, $opt, $body) = @_;
20         my (@args, $message, $out, $startlocale);
21
22         unless ($opt->{raw}) {
23                 if (ref $opt->{arg} eq 'ARRAY') {
24                         @args = @{ $opt->{arg} };
25                 } elsif (ref $opt->{arg} eq 'HASH') {
26                         @args = map { $opt->{arg}->{$_} } sort keys %{ $opt->{arg} };
27                 } elsif (! ref $opt->{arg}) {
28                         @args = $opt->{arg};
29                 }
30         }
31
32         if ($opt->{locale}) {
33                 # we only mess with scratch mv_locale because
34                 # Vend::Util::find_locale_bit uses it to determine current locale
35                 $startlocale = $::Scratch->{mv_locale};
36                 Vend::Util::setlocale($opt->{locale}, undef, { persist => 1 });
37         }
38
39         if ($opt->{inline}) {
40                 $message = Vend::Util::find_locale_bit($body);
41         } else {
42                 $message = $body;
43         }
44
45         if ($key) {
46                 if ($Vend::Cfg->{Locale} and defined $Vend::Cfg->{Locale}{$key}) {
47                         $message = $Vend::Cfg->{Locale}{$key};
48                 } elsif ($Global::Locale and defined $Global::Locale->{$key}) {
49                         $message = $Global::Locale->{$key};
50                 }
51         }
52
53         if ($opt->{raw}) {
54                 $out = $message;
55         } else {
56                 $out = errmsg($message, @args);
57         }
58
59         if ($opt->{locale}) {
60                 $::Scratch->{mv_locale} = $startlocale;
61                 Vend::Util::setlocale();
62         }
63
64         return $out;
65 }
66 EOR