1 # Copyright 2002-2007 Interchange Development Group and others
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.
8 # $Id: msg.coretag,v 1.4 2007-03-30 23:40:49 pajamian Exp $
12 UserTag msg attrAlias lc inline
14 UserTag msg Interpolate
15 UserTag msg PosNumber 1
16 UserTag msg Version $Revision: 1.4 $
17 UserTag msg Routine <<EOR
19 my ($key, $opt, $body) = @_;
20 my (@args, $message, $out, $startlocale);
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}) {
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 });
40 $message = Vend::Util::find_locale_bit($body);
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};
56 $out = errmsg($message, @args);
60 $::Scratch->{mv_locale} = $startlocale;
61 Vend::Util::setlocale();