line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Template::Compiled::Plugin::I18N::DefaultTranslator;
|
2
|
|
|
|
|
|
|
|
3
|
16
|
|
|
16
|
|
30428
|
use strict;
|
|
16
|
|
|
|
|
34
|
|
|
16
|
|
|
|
|
728
|
|
4
|
16
|
|
|
16
|
|
92
|
use warnings;
|
|
16
|
|
|
|
|
35
|
|
|
16
|
|
|
|
|
539
|
|
5
|
|
|
|
|
|
|
|
6
|
16
|
|
|
16
|
|
86
|
use Carp qw(croak);
|
|
16
|
|
|
|
|
30
|
|
|
16
|
|
|
|
|
815
|
|
7
|
16
|
|
|
16
|
|
738
|
use HTML::Template::Compiled::Plugin::I18N;
|
|
16
|
|
|
|
|
31
|
|
|
16
|
|
|
|
|
10377
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '1.02';
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $escape_ref = sub {
|
12
|
|
|
|
|
|
|
my $string = shift;
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
defined $string
|
15
|
|
|
|
|
|
|
and return $string;
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
return 'undef';
|
18
|
|
|
|
|
|
|
};
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub set_escape {
|
21
|
1
|
|
|
1
|
1
|
25
|
my (undef, $code_ref) = @_;
|
22
|
|
|
|
|
|
|
|
23
|
1
|
50
|
|
|
|
6
|
ref $code_ref eq 'CODE'
|
24
|
|
|
|
|
|
|
or croak 'Coderef expected';
|
25
|
1
|
|
|
|
|
2
|
$escape_ref = $code_ref;
|
26
|
|
|
|
|
|
|
|
27
|
1
|
|
|
|
|
3
|
return;
|
28
|
|
|
|
|
|
|
}
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub get_escape {
|
31
|
117
|
|
|
117
|
1
|
323
|
return $escape_ref;
|
32
|
|
|
|
|
|
|
}
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub translate {
|
35
|
48
|
|
|
48
|
1
|
26443
|
my (undef, $attr_ref) = @_;
|
36
|
|
|
|
|
|
|
|
37
|
48
|
100
|
|
|
|
203
|
if ( exists $attr_ref->{escape} ) {
|
38
|
15
|
|
|
|
|
43
|
my $escape = delete $attr_ref->{escape};
|
39
|
|
|
|
|
|
|
ESCAPE_SCALAR:
|
40
|
15
|
|
|
|
|
40
|
for ( qw(text plural) ) {
|
41
|
30
|
100
|
|
|
|
128
|
exists $attr_ref->{$_}
|
42
|
|
|
|
|
|
|
or next ESCAPE_SCALAR;
|
43
|
15
|
|
|
|
|
90
|
$attr_ref->{$_} = HTML::Template::Compiled::Plugin::I18N->escape(
|
44
|
|
|
|
|
|
|
$attr_ref->{$_},
|
45
|
|
|
|
|
|
|
$escape,
|
46
|
|
|
|
|
|
|
);
|
47
|
|
|
|
|
|
|
}
|
48
|
|
|
|
|
|
|
ESCAPE_ARRAYREF:
|
49
|
15
|
|
|
|
|
40
|
for ( qw(maketext) ) {
|
50
|
15
|
100
|
|
|
|
68
|
exists $attr_ref->{$_}
|
51
|
|
|
|
|
|
|
or next ESCAPE_ARRAYREF;
|
52
|
2
|
|
|
|
|
6
|
for my $value ( @{ $attr_ref->{$_} } ) {
|
|
2
|
|
|
|
|
24
|
|
53
|
2
|
|
|
|
|
10
|
$value = HTML::Template::Compiled::Plugin::I18N->escape(
|
54
|
|
|
|
|
|
|
$value,
|
55
|
|
|
|
|
|
|
$escape,
|
56
|
|
|
|
|
|
|
);
|
57
|
|
|
|
|
|
|
}
|
58
|
|
|
|
|
|
|
}
|
59
|
|
|
|
|
|
|
ESCAPE_HASHREF:
|
60
|
15
|
|
|
|
|
40
|
for ( qw(gettext) ) {
|
61
|
15
|
100
|
|
|
|
73
|
exists $attr_ref->{$_}
|
62
|
|
|
|
|
|
|
or next ESCAPE_HASHREF;
|
63
|
2
|
|
|
|
|
4
|
for my $value ( values %{ $attr_ref->{$_} } ) {
|
|
2
|
|
|
|
|
16
|
|
64
|
2
|
|
|
|
|
10
|
$value = HTML::Template::Compiled::Plugin::I18N->escape(
|
65
|
|
|
|
|
|
|
$value,
|
66
|
|
|
|
|
|
|
$escape,
|
67
|
|
|
|
|
|
|
);
|
68
|
|
|
|
|
|
|
}
|
69
|
|
|
|
|
|
|
}
|
70
|
|
|
|
|
|
|
}
|
71
|
|
|
|
|
|
|
|
72
|
115
|
|
|
|
|
334
|
return join q{;}, map {
|
73
|
48
|
|
|
|
|
118
|
exists $attr_ref->{$_}
|
74
|
|
|
|
|
|
|
? (
|
75
|
|
|
|
|
|
|
"$_="
|
76
|
|
|
|
|
|
|
. join q{,}, map {
|
77
|
9
|
|
|
|
|
56
|
__PACKAGE__->get_escape()->($_);
|
78
|
|
|
|
|
|
|
} (
|
79
|
|
|
|
|
|
|
ref $attr_ref->{$_} eq 'ARRAY'
|
80
|
|
|
|
|
|
|
? @{ $attr_ref->{$_} }
|
81
|
|
|
|
|
|
|
: ref $attr_ref->{$_} eq 'HASH'
|
82
|
384
|
100
|
|
|
|
2696
|
? do {
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
83
|
15
|
|
|
|
|
29
|
my $key = $_;
|
84
|
20
|
|
|
|
|
72
|
map {
|
85
|
15
|
|
|
|
|
134
|
( $_, $attr_ref->{$key}->{$_} );
|
86
|
15
|
|
|
|
|
26
|
} sort keys %{ $attr_ref->{$key} };
|
87
|
|
|
|
|
|
|
}
|
88
|
|
|
|
|
|
|
: $attr_ref->{$_}
|
89
|
|
|
|
|
|
|
)
|
90
|
|
|
|
|
|
|
)
|
91
|
|
|
|
|
|
|
: ();
|
92
|
|
|
|
|
|
|
} qw(
|
93
|
|
|
|
|
|
|
context text plural count maketext gettext formatter unescaped
|
94
|
|
|
|
|
|
|
);
|
95
|
|
|
|
|
|
|
}
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1;
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
__END__
|