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