| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
4
|
|
|
4
|
|
50
|
use 5.008001; |
|
|
4
|
|
|
|
|
7
|
|
|
2
|
4
|
|
|
4
|
|
11
|
use utf8; |
|
|
4
|
|
|
|
|
3
|
|
|
|
4
|
|
|
|
|
15
|
|
|
3
|
4
|
|
|
4
|
|
66
|
use strict; |
|
|
4
|
|
|
|
|
3
|
|
|
|
4
|
|
|
|
|
62
|
|
|
4
|
4
|
|
|
4
|
|
12
|
use warnings; |
|
|
4
|
|
|
|
|
2
|
|
|
|
4
|
|
|
|
|
88
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
11
|
use Locale::KeyedText::Message 2.001000; |
|
|
4
|
|
|
|
|
48
|
|
|
|
4
|
|
|
|
|
194
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
########################################################################### |
|
9
|
|
|
|
|
|
|
########################################################################### |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
{ package Locale::KeyedText::Translator; # class |
|
12
|
|
|
|
|
|
|
BEGIN { |
|
13
|
4
|
|
|
4
|
|
7
|
our $VERSION = '2.001000'; |
|
14
|
4
|
|
|
|
|
159
|
$VERSION = eval $VERSION; |
|
15
|
|
|
|
|
|
|
} |
|
16
|
|
|
|
|
|
|
|
|
17
|
4
|
|
|
4
|
|
13
|
use Scalar::Util 'blessed'; |
|
|
4
|
|
|
|
|
4
|
|
|
|
4
|
|
|
|
|
1853
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# has _set_names |
|
20
|
|
|
|
|
|
|
# isa ArrayRef |
|
21
|
|
|
|
|
|
|
# One elem per set name: |
|
22
|
|
|
|
|
|
|
# elem is Str |
|
23
|
|
|
|
|
|
|
# default [] |
|
24
|
|
|
|
|
|
|
# List of Template module Set Names to search. |
|
25
|
|
|
|
|
|
|
sub _set_names { |
|
26
|
99
|
|
|
99
|
|
71
|
my $self = shift; |
|
27
|
99
|
100
|
|
|
|
213
|
$self->{_set_names} = $_[0] if scalar @_; |
|
28
|
99
|
|
|
|
|
108
|
return $self->{_set_names}; |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# has _member_names |
|
32
|
|
|
|
|
|
|
# isa ArrayRef |
|
33
|
|
|
|
|
|
|
# One elem per member name: |
|
34
|
|
|
|
|
|
|
# elem is Str |
|
35
|
|
|
|
|
|
|
# default [] |
|
36
|
|
|
|
|
|
|
# List of Template module Member Names to search. |
|
37
|
|
|
|
|
|
|
sub _member_names { |
|
38
|
87
|
|
|
87
|
|
61
|
my $self = shift; |
|
39
|
87
|
100
|
|
|
|
132
|
$self->{_member_names} = $_[0] if scalar @_; |
|
40
|
87
|
|
|
|
|
148
|
return $self->{_member_names}; |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
########################################################################### |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub new { |
|
46
|
25
|
|
|
25
|
0
|
6659
|
my ($class, @args) = @_; |
|
47
|
25
|
|
33
|
|
|
110
|
$class = (blessed $class) || $class; |
|
48
|
|
|
|
|
|
|
|
|
49
|
25
|
|
|
|
|
40
|
my $params = $class->BUILDARGS( @args ); |
|
50
|
|
|
|
|
|
|
|
|
51
|
25
|
|
|
|
|
36
|
my $self = bless {}, $class; |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# Set attribute default values. |
|
54
|
25
|
|
|
|
|
45
|
$self->_set_names( [] ); |
|
55
|
25
|
|
|
|
|
35
|
$self->_member_names( [] ); |
|
56
|
|
|
|
|
|
|
|
|
57
|
25
|
|
|
|
|
38
|
$self->BUILD( $params ); |
|
58
|
|
|
|
|
|
|
|
|
59
|
21
|
|
|
|
|
51
|
return $self; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
########################################################################### |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub BUILDARGS { |
|
65
|
25
|
|
|
25
|
0
|
27
|
my ($class, @args) = @_; |
|
66
|
25
|
50
|
33
|
|
|
105
|
if (@args == 1 and ref $args[0] eq 'HASH') { |
|
|
|
0
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# Constructor was called with (possibly zero) named arguments. |
|
68
|
25
|
|
|
|
|
22
|
return { %{$args[0]} }; |
|
|
25
|
|
|
|
|
83
|
|
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
elsif ((scalar @args % 2) == 0) { |
|
71
|
|
|
|
|
|
|
# Constructor was called with (possibly zero) named arguments. |
|
72
|
0
|
|
|
|
|
0
|
return { @args }; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
else { |
|
75
|
|
|
|
|
|
|
# Constructor was called with odd number positional arguments. |
|
76
|
0
|
|
|
|
|
0
|
$class->_die_with_msg( 'LKT_ARGS_BAD_PSEUDO_NAMED' ); |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
########################################################################### |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub BUILD { |
|
83
|
25
|
|
|
25
|
0
|
22
|
my ($self, $args) = @_; |
|
84
|
|
|
|
|
|
|
my ($set_names_ref, $member_names_ref) |
|
85
|
25
|
|
|
|
|
19
|
= @{$args}{'set_names', 'member_names'}; |
|
|
25
|
|
|
|
|
32
|
|
|
86
|
|
|
|
|
|
|
|
|
87
|
25
|
100
|
|
|
|
42
|
if (ref $set_names_ref ne 'ARRAY') { |
|
88
|
5
|
|
|
|
|
6
|
$set_names_ref = [$set_names_ref]; |
|
89
|
|
|
|
|
|
|
} |
|
90
|
25
|
100
|
|
|
|
36
|
if (ref $member_names_ref ne 'ARRAY') { |
|
91
|
5
|
|
|
|
|
5
|
$member_names_ref = [$member_names_ref]; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
25
|
|
|
|
|
36
|
$self->_assert_arg_ary( 'new', ':@set_names!', $set_names_ref ); |
|
95
|
23
|
|
|
|
|
32
|
$self->_assert_arg_ary( 'new', ':@member_names!', $member_names_ref ); |
|
96
|
|
|
|
|
|
|
|
|
97
|
21
|
|
|
|
|
17
|
$self->_set_names( [@{$set_names_ref}] ); |
|
|
21
|
|
|
|
|
31
|
|
|
98
|
21
|
|
|
|
|
19
|
$self->_member_names( [@{$member_names_ref}] ); |
|
|
21
|
|
|
|
|
30
|
|
|
99
|
|
|
|
|
|
|
|
|
100
|
21
|
|
|
|
|
21
|
return; |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
########################################################################### |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub export_as_hash { |
|
106
|
0
|
|
|
0
|
0
|
0
|
my ($self) = @_; |
|
107
|
|
|
|
|
|
|
return { |
|
108
|
0
|
|
|
|
|
0
|
'set_names' => [@{$self->_set_names()}], |
|
109
|
0
|
|
|
|
|
0
|
'member_names' => [@{$self->_member_names()}], |
|
|
0
|
|
|
|
|
0
|
|
|
110
|
|
|
|
|
|
|
}; |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
########################################################################### |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub get_set_names { |
|
116
|
1
|
|
|
1
|
0
|
348
|
my ($self) = @_; |
|
117
|
1
|
|
|
|
|
2
|
return [@{$self->_set_names()}]; |
|
|
1
|
|
|
|
|
3
|
|
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub get_member_names { |
|
121
|
1
|
|
|
1
|
0
|
374
|
my ($self) = @_; |
|
122
|
1
|
|
|
|
|
1
|
return [@{$self->_member_names()}]; |
|
|
1
|
|
|
|
|
2
|
|
|
123
|
|
|
|
|
|
|
} |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
########################################################################### |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub as_debug_string { |
|
128
|
0
|
|
|
0
|
0
|
0
|
my ($self) = @_; |
|
129
|
0
|
|
|
|
|
0
|
my $set_names = $self->_set_names(); |
|
130
|
0
|
|
|
|
|
0
|
my $member_names = $self->_member_names(); |
|
131
|
|
|
|
|
|
|
return ' Debug String of a Locale::KeyedText::Translator object:' |
|
132
|
|
|
|
|
|
|
. "\n" |
|
133
|
0
|
|
|
|
|
0
|
. ' @set_names: ["' . (join q{", "}, @{$set_names}) . '"]' |
|
134
|
|
|
|
|
|
|
. "\n" |
|
135
|
|
|
|
|
|
|
. ' @member_names: ["' |
|
136
|
0
|
|
|
|
|
0
|
. (join q{", "}, @{$member_names}) . '"]' |
|
|
0
|
|
|
|
|
0
|
|
|
137
|
|
|
|
|
|
|
. "\n"; |
|
138
|
|
|
|
|
|
|
} |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
use overload ( |
|
141
|
4
|
|
|
|
|
19
|
'""' => \&as_debug_string, |
|
142
|
|
|
|
|
|
|
fallback => 1, |
|
143
|
4
|
|
|
4
|
|
17
|
); |
|
|
4
|
|
|
|
|
5
|
|
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub as_debug_str { |
|
146
|
21
|
|
|
21
|
0
|
4353
|
my ($self) = @_; |
|
147
|
21
|
|
|
|
|
33
|
my $set_names = $self->_set_names(); |
|
148
|
21
|
|
|
|
|
34
|
my $member_names = $self->_member_names(); |
|
149
|
21
|
|
|
|
|
47
|
return 'SETS: ' . (join ', ', @{$set_names}) . '; ' |
|
150
|
21
|
|
|
|
|
18
|
. 'MEMBERS: ' . (join ', ', @{$member_names}); |
|
|
21
|
|
|
|
|
70
|
|
|
151
|
|
|
|
|
|
|
} |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
########################################################################### |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub get_set_member_combinations { |
|
156
|
19
|
|
|
19
|
0
|
38
|
my ($self) = @_; |
|
157
|
19
|
|
|
|
|
20
|
my @combinations = (); |
|
158
|
19
|
|
|
|
|
9
|
for my $member_name (@{$self->_member_names()}) { |
|
|
19
|
|
|
|
|
25
|
|
|
159
|
31
|
|
|
|
|
20
|
for my $set_name (@{$self->_set_names()}) { |
|
|
31
|
|
|
|
|
36
|
|
|
160
|
55
|
|
|
|
|
93
|
push @combinations, $set_name . $member_name; |
|
161
|
|
|
|
|
|
|
} |
|
162
|
|
|
|
|
|
|
} |
|
163
|
19
|
|
|
|
|
26
|
return \@combinations; |
|
164
|
|
|
|
|
|
|
} |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
########################################################################### |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
sub translate_message { |
|
169
|
21
|
|
|
21
|
0
|
6204
|
my ($self, $message) = @_; |
|
170
|
|
|
|
|
|
|
|
|
171
|
21
|
|
|
|
|
34
|
$self->_assert_arg_msg( 'translate_message', '$message!', $message ); |
|
172
|
|
|
|
|
|
|
|
|
173
|
19
|
|
|
|
|
20
|
my $text = undef; |
|
174
|
|
|
|
|
|
|
SET_MEMBER: |
|
175
|
19
|
|
|
|
|
12
|
for my $module_name (@{$self->get_set_member_combinations()}) { |
|
|
19
|
|
|
|
|
27
|
|
|
176
|
|
|
|
|
|
|
# Determine if requested template module is already loaded. |
|
177
|
|
|
|
|
|
|
# It may have been embedded in a core program file and hence |
|
178
|
|
|
|
|
|
|
# should never be loaded by translate_message(). |
|
179
|
23
|
|
|
|
|
29
|
my $module_is_loaded |
|
180
|
|
|
|
|
|
|
= $self->template_module_is_loaded( $module_name ); |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
# Try to load an external Perl template module; on a require |
|
183
|
|
|
|
|
|
|
# failure, we assume that module intentionally doesn't exist, |
|
184
|
|
|
|
|
|
|
# and so skip to the next candidate module name. |
|
185
|
23
|
100
|
|
|
|
32
|
if (!$module_is_loaded) { |
|
186
|
4
|
|
|
|
|
5
|
eval { |
|
187
|
4
|
|
|
|
|
7
|
$self->load_template_module( $module_name ); |
|
188
|
|
|
|
|
|
|
}; |
|
189
|
|
|
|
|
|
|
next SET_MEMBER |
|
190
|
4
|
50
|
|
|
|
7
|
if $@; |
|
191
|
|
|
|
|
|
|
} |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
# Try to fetch template text for the given message key from the |
|
194
|
|
|
|
|
|
|
# successfully loaded template module; on a function call |
|
195
|
|
|
|
|
|
|
# death, assume module is damaged and say so; an undefined |
|
196
|
|
|
|
|
|
|
# ret val means module doesn't define key, skip to next module. |
|
197
|
23
|
|
|
|
|
46
|
$text = $self->get_template_text_from_loaded_module( $module_name, |
|
198
|
|
|
|
|
|
|
$message->get_msg_key() ); # let escape any thrown exception |
|
199
|
|
|
|
|
|
|
next SET_MEMBER |
|
200
|
23
|
100
|
|
|
|
37
|
if !defined $text; |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
# We successfully got template text for the message key, so |
|
203
|
|
|
|
|
|
|
# interpolate the message vars into it and return that. |
|
204
|
18
|
|
|
|
|
30
|
$text = $self->interpolate_vars_into_template_text( |
|
205
|
|
|
|
|
|
|
$text, $message->get_msg_vars() ); |
|
206
|
18
|
|
|
|
|
37
|
last SET_MEMBER; |
|
207
|
|
|
|
|
|
|
} |
|
208
|
|
|
|
|
|
|
|
|
209
|
19
|
|
|
|
|
62
|
return $text; |
|
210
|
|
|
|
|
|
|
} |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
########################################################################### |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
sub template_module_is_loaded { |
|
215
|
23
|
|
|
23
|
0
|
21
|
my ($self, $module_name) = @_; |
|
216
|
23
|
|
|
|
|
29
|
$self->_assert_arg_str( 'template_module_is_loaded', |
|
217
|
|
|
|
|
|
|
'$module_name!', $module_name ); |
|
218
|
4
|
|
|
4
|
|
1168
|
no strict 'refs'; |
|
|
4
|
|
|
|
|
4
|
|
|
|
4
|
|
|
|
|
2199
|
|
|
219
|
23
|
|
|
|
|
13
|
return scalar keys %{$module_name . '::'}; |
|
|
23
|
|
|
|
|
53
|
|
|
220
|
|
|
|
|
|
|
} |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
sub load_template_module { |
|
223
|
4
|
|
|
4
|
0
|
4
|
my ($self, $module_name) = @_; |
|
224
|
|
|
|
|
|
|
|
|
225
|
4
|
|
|
|
|
5
|
$self->_assert_arg_str( 'load_template_module', |
|
226
|
|
|
|
|
|
|
'$module_name!', $module_name ); |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
# Note: We have to invoke this 'require' in an eval string |
|
229
|
|
|
|
|
|
|
# because we need the bareword semantics, where 'require' |
|
230
|
|
|
|
|
|
|
# will munge the package name into file system paths. |
|
231
|
4
|
|
|
|
|
199
|
eval "require $module_name;"; |
|
232
|
4
|
50
|
|
|
|
648
|
$self->_die_with_msg( 'LKT_T_FAIL_LOAD_TMPL_MOD', |
|
233
|
|
|
|
|
|
|
{ 'METH' => 'load_template_module', |
|
234
|
|
|
|
|
|
|
'TMPL_MOD_NAME' => $module_name, 'REASON' => $@ } ) |
|
235
|
|
|
|
|
|
|
if $@; |
|
236
|
|
|
|
|
|
|
|
|
237
|
4
|
|
|
|
|
7
|
return; |
|
238
|
|
|
|
|
|
|
} |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
sub get_template_text_from_loaded_module { |
|
241
|
23
|
|
|
23
|
0
|
20
|
my ($self, $module_name, $msg_key) = @_; |
|
242
|
|
|
|
|
|
|
|
|
243
|
23
|
|
|
|
|
26
|
$self->_assert_arg_str( 'get_template_text_from_loaded_module', |
|
244
|
|
|
|
|
|
|
'$module_name!', $module_name ); |
|
245
|
23
|
|
|
|
|
26
|
$self->_assert_arg_str( 'get_template_text_from_loaded_module', |
|
246
|
|
|
|
|
|
|
'$msg_key!', $msg_key ); |
|
247
|
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
# TODO: Use a "can" test to suss out whether a call would work before trying it. |
|
249
|
|
|
|
|
|
|
|
|
250
|
23
|
|
|
|
|
17
|
my $text = undef; |
|
251
|
23
|
|
|
|
|
19
|
eval { |
|
252
|
23
|
|
|
|
|
48
|
$text = $module_name->get_text_by_key( $msg_key ); |
|
253
|
|
|
|
|
|
|
}; |
|
254
|
23
|
50
|
|
|
|
90
|
$self->_die_with_msg( 'LKT_T_FAIL_GET_TMPL_TEXT', |
|
255
|
|
|
|
|
|
|
{ 'METH' => 'get_template_text_from_loaded_module', |
|
256
|
|
|
|
|
|
|
'TMPL_MOD_NAME' => $module_name, 'REASON' => $@ } ) |
|
257
|
|
|
|
|
|
|
if $@; |
|
258
|
|
|
|
|
|
|
|
|
259
|
23
|
|
|
|
|
22
|
return $text; |
|
260
|
|
|
|
|
|
|
} |
|
261
|
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
sub interpolate_vars_into_template_text { |
|
263
|
18
|
|
|
18
|
0
|
17
|
my ($self, $text, $msg_vars_ref) = @_; |
|
264
|
|
|
|
|
|
|
|
|
265
|
18
|
50
|
|
|
|
25
|
$self->_die_with_msg( 'LKT_ARG_UNDEF', |
|
266
|
|
|
|
|
|
|
{ 'METH' => 'interpolate_vars_into_template_text', |
|
267
|
|
|
|
|
|
|
'ARG' => '$text!' } ) |
|
268
|
|
|
|
|
|
|
if !defined $text; |
|
269
|
18
|
|
|
|
|
25
|
$self->_assert_arg_hash( 'interpolate_vars_into_template_text', |
|
270
|
|
|
|
|
|
|
'%msg_vars!', $msg_vars_ref ); |
|
271
|
|
|
|
|
|
|
|
|
272
|
18
|
|
|
|
|
13
|
while (my ($var_name, $var_value) = each %{$msg_vars_ref}) { |
|
|
37
|
|
|
|
|
85
|
|
|
273
|
19
|
100
|
|
|
|
50
|
my $var_value_as_str |
|
274
|
|
|
|
|
|
|
= defined $var_value ? "$var_value" |
|
275
|
|
|
|
|
|
|
: q{} |
|
276
|
|
|
|
|
|
|
; |
|
277
|
19
|
|
|
|
|
221
|
$text =~ s/ \< $var_name \> /$var_value_as_str/xg; |
|
278
|
|
|
|
|
|
|
} |
|
279
|
|
|
|
|
|
|
|
|
280
|
18
|
|
|
|
|
24
|
return $text; |
|
281
|
|
|
|
|
|
|
} |
|
282
|
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
########################################################################### |
|
284
|
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
sub _die_with_msg { |
|
286
|
6
|
|
|
6
|
|
5
|
my ($self, $msg_key, $msg_vars_ref) = @_; |
|
287
|
6
|
|
50
|
|
|
10
|
$msg_vars_ref ||= {}; |
|
288
|
6
|
|
|
|
|
14
|
$msg_vars_ref->{'CLASS'} = 'Locale::KeyedText::Translator'; |
|
289
|
6
|
|
|
|
|
22
|
die Locale::KeyedText::Message->new({ |
|
290
|
|
|
|
|
|
|
'msg_key' => $msg_key, 'msg_vars' => $msg_vars_ref }); |
|
291
|
|
|
|
|
|
|
} |
|
292
|
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
sub _assert_arg_str { |
|
294
|
73
|
|
|
73
|
|
55
|
my ($self, $meth, $arg, $val) = @_; |
|
295
|
73
|
50
|
|
|
|
90
|
$self->_die_with_msg( 'LKT_ARG_UNDEF', |
|
296
|
|
|
|
|
|
|
{ 'METH' => $meth, 'ARG' => $arg } ) |
|
297
|
|
|
|
|
|
|
if !defined $val; |
|
298
|
73
|
50
|
|
|
|
96
|
$self->_die_with_msg( 'LKT_ARG_EMP_STR', |
|
299
|
|
|
|
|
|
|
{ 'METH' => $meth, 'ARG' => $arg } ) |
|
300
|
|
|
|
|
|
|
if $val eq q{}; |
|
301
|
|
|
|
|
|
|
} |
|
302
|
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
sub _assert_arg_ary { |
|
304
|
48
|
|
|
48
|
|
42
|
my ($self, $meth, $arg, $val) = @_; |
|
305
|
48
|
50
|
|
|
|
61
|
$self->_die_with_msg( 'LKT_ARG_UNDEF', |
|
306
|
|
|
|
|
|
|
{ 'METH' => $meth, 'ARG' => $arg } ) |
|
307
|
|
|
|
|
|
|
if !defined $val; |
|
308
|
48
|
50
|
|
|
|
67
|
$self->_die_with_msg( 'LKT_ARG_NO_ARY', |
|
309
|
|
|
|
|
|
|
{ 'METH' => $meth, 'ARG' => $arg, 'VAL' => $val } ) |
|
310
|
|
|
|
|
|
|
if ref $val ne 'ARRAY'; |
|
311
|
|
|
|
|
|
|
$self->_die_with_msg( 'LKT_ARG_ARY_NO_ELEMS', |
|
312
|
|
|
|
|
|
|
{ 'METH' => $meth, 'ARG' => $arg } ) |
|
313
|
48
|
100
|
|
|
|
26
|
if @{$val} == 0; |
|
|
48
|
|
|
|
|
77
|
|
|
314
|
46
|
|
|
|
|
28
|
for my $val_elem (@{$val}) { |
|
|
46
|
|
|
|
|
57
|
|
|
315
|
60
|
100
|
|
|
|
72
|
$self->_die_with_msg( 'LKT_ARG_ARY_ELEM_UNDEF', |
|
316
|
|
|
|
|
|
|
{ 'METH' => $meth, 'ARG' => $arg } ) |
|
317
|
|
|
|
|
|
|
if !defined $val_elem; |
|
318
|
58
|
50
|
|
|
|
94
|
$self->_die_with_msg( 'LKT_ARG_ARY_ELEM_EMP_STR', |
|
319
|
|
|
|
|
|
|
{ 'METH' => $meth, 'ARG' => $arg } ) |
|
320
|
|
|
|
|
|
|
if $val_elem eq q{}; |
|
321
|
|
|
|
|
|
|
} |
|
322
|
|
|
|
|
|
|
} |
|
323
|
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
sub _assert_arg_hash { |
|
325
|
18
|
|
|
18
|
|
18
|
my ($self, $meth, $arg, $val) = @_; |
|
326
|
18
|
50
|
|
|
|
20
|
$self->_die_with_msg( 'LKT_ARG_UNDEF', |
|
327
|
|
|
|
|
|
|
{ 'METH' => $meth, 'ARG' => $arg } ) |
|
328
|
|
|
|
|
|
|
if !defined $val; |
|
329
|
18
|
50
|
|
|
|
28
|
$self->_die_with_msg( 'LKT_ARG_NO_HASH', |
|
330
|
|
|
|
|
|
|
{ 'METH' => $meth, 'ARG' => $arg, 'VAL' => $val } ) |
|
331
|
|
|
|
|
|
|
if ref $val ne 'HASH'; |
|
332
|
|
|
|
|
|
|
$self->_die_with_msg( 'LKT_ARG_HASH_KEY_EMP_STR', |
|
333
|
|
|
|
|
|
|
{ 'METH' => $meth, 'ARG' => $arg } ) |
|
334
|
18
|
50
|
|
|
|
29
|
if exists $val->{q{}}; |
|
335
|
|
|
|
|
|
|
} |
|
336
|
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
sub _assert_arg_msg { |
|
338
|
21
|
|
|
21
|
|
20
|
my ($self, $meth, $arg, $val) = @_; |
|
339
|
21
|
50
|
|
|
|
39
|
$self->_die_with_msg( 'LKT_ARG_UNDEF', |
|
340
|
|
|
|
|
|
|
{ 'METH' => $meth, 'ARG' => $arg } ) |
|
341
|
|
|
|
|
|
|
if !defined $val; |
|
342
|
21
|
100
|
66
|
|
|
151
|
$self->_die_with_msg( 'LKT_ARG_NO_EXP_TYPE', { 'METH' => $meth, |
|
343
|
|
|
|
|
|
|
'ARG' => $arg, 'EXP_TYPE' => 'Locale::KeyedText::Message', |
|
344
|
|
|
|
|
|
|
'VAL' => $val } ) |
|
345
|
|
|
|
|
|
|
if !blessed $val or !$val->isa( 'Locale::KeyedText::Message' ); |
|
346
|
|
|
|
|
|
|
} |
|
347
|
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
########################################################################### |
|
349
|
|
|
|
|
|
|
|
|
350
|
|
|
|
|
|
|
} # class Locale::KeyedText::Translator |
|
351
|
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
########################################################################### |
|
353
|
|
|
|
|
|
|
########################################################################### |
|
354
|
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
1; |