line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#! /bin/false |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Copyright (C) 2016-2018 Guido Flohr , |
4
|
|
|
|
|
|
|
# all rights reserved. |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify it |
7
|
|
|
|
|
|
|
# under the terms of the GNU Library General Public License as published |
8
|
|
|
|
|
|
|
# by the Free Software Foundation; either version 2, or (at your option) |
9
|
|
|
|
|
|
|
# any later version. |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful, |
12
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
13
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14
|
|
|
|
|
|
|
# Library General Public License for more details. |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# You should have received a copy of the GNU Library General Public |
17
|
|
|
|
|
|
|
# License along with this program; if not, write to the Free Software |
18
|
|
|
|
|
|
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
19
|
|
|
|
|
|
|
# USA. |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
package Locale::XGettext::TT2; |
22
|
|
|
|
|
|
|
$Locale::XGettext::TT2::VERSION = '0.8'; |
23
|
7
|
|
|
7
|
|
473879
|
use strict; |
|
7
|
|
|
|
|
73
|
|
|
7
|
|
|
|
|
246
|
|
24
|
|
|
|
|
|
|
|
25
|
7
|
|
|
7
|
|
3937
|
use Locale::TextDomain qw(Template-Plugin-Gettext); |
|
7
|
|
|
|
|
131926
|
|
|
7
|
|
|
|
|
49
|
|
26
|
7
|
|
|
7
|
|
213009
|
use Template; |
|
7
|
|
|
|
|
133574
|
|
|
7
|
|
|
|
|
276
|
|
27
|
|
|
|
|
|
|
|
28
|
7
|
|
|
7
|
|
3888
|
use Locale::XGettext 0.7; |
|
7
|
|
|
|
|
221032
|
|
|
7
|
|
|
|
|
271
|
|
29
|
7
|
|
|
7
|
|
79
|
use base qw(Locale::XGettext); |
|
7
|
|
|
|
|
17
|
|
|
7
|
|
|
|
|
2884
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub versionInformation { |
32
|
0
|
|
|
0
|
1
|
0
|
return __x('{program} (Template-Plugin-Gettext) {version} |
33
|
|
|
|
|
|
|
Copyright (C) {years} Cantanea EOOD (http://www.cantanea.com/). |
34
|
|
|
|
|
|
|
License GPLv3+: GNU GPL version 3 or later |
35
|
|
|
|
|
|
|
This is free software: you are free to change and redistribute it. |
36
|
|
|
|
|
|
|
There is NO WARRANTY, to the extent permitted by law. |
37
|
|
|
|
|
|
|
Written by Guido Flohr (http://www.guido-flohr.net/). |
38
|
|
|
|
|
|
|
', |
39
|
|
|
|
|
|
|
program => $0, years => '2016-2018', |
40
|
|
|
|
|
|
|
version => $Locale::XGettext::TT2::VERSION); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub fileInformation { |
44
|
0
|
|
|
0
|
1
|
0
|
return __(<
|
45
|
|
|
|
|
|
|
The input files should be templates for the Template::Toolkit |
46
|
|
|
|
|
|
|
(http://www.template-toolkit.org/). The strings are usually marked and |
47
|
|
|
|
|
|
|
made translatable with the help of "Template::Plugin::Gettext". Try the |
48
|
|
|
|
|
|
|
command "perldoc Template::Plugin::Gettext" for more information. |
49
|
|
|
|
|
|
|
EOF |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub canExtractAll { |
53
|
0
|
|
|
0
|
1
|
0
|
shift; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub canKeywords { |
57
|
0
|
|
|
0
|
1
|
0
|
shift; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub languageSpecificOptions { |
61
|
|
|
|
|
|
|
return [ |
62
|
|
|
|
|
|
|
[ |
63
|
0
|
|
|
0
|
1
|
0
|
'plugin|plug-in:s', |
64
|
|
|
|
|
|
|
'plug_in', |
65
|
|
|
|
|
|
|
' --plug-in=PLUG-IN, --plugin=PLUG-IN', |
66
|
|
|
|
|
|
|
__"the plug-in name (defaults to 'Gettext'), can be an empty string", |
67
|
|
|
|
|
|
|
] |
68
|
|
|
|
|
|
|
]; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub defaultKeywords { |
72
|
|
|
|
|
|
|
return [ |
73
|
10
|
|
|
10
|
1
|
41252
|
'gettext:1', |
74
|
|
|
|
|
|
|
'ngettext:1,2', |
75
|
|
|
|
|
|
|
'pgettext:1c,2', |
76
|
|
|
|
|
|
|
'gettextp:1,2c', |
77
|
|
|
|
|
|
|
'npgettext:1c,2,3', |
78
|
|
|
|
|
|
|
'ngettextp:1,2,3c', |
79
|
|
|
|
|
|
|
'xgettext:1', |
80
|
|
|
|
|
|
|
'nxgettext:1,2', |
81
|
|
|
|
|
|
|
'pxgettext:1c,2', |
82
|
|
|
|
|
|
|
'xgettextp:1,2c', |
83
|
|
|
|
|
|
|
'npxgettext:1c,2,3', |
84
|
|
|
|
|
|
|
'nxgettextp:1,2,3c', |
85
|
|
|
|
|
|
|
]; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub defaultFlags { |
89
|
|
|
|
|
|
|
return [ |
90
|
10
|
|
|
10
|
1
|
11432
|
"xgettext:1:perl-brace-format", |
91
|
|
|
|
|
|
|
"nxgettext:1:perl-brace-format", |
92
|
|
|
|
|
|
|
"nxgettext:2:perl-brace-format", |
93
|
|
|
|
|
|
|
"pxgettext:2:perl-brace-format", |
94
|
|
|
|
|
|
|
"xgettextp:1:perl-brace-format", |
95
|
|
|
|
|
|
|
"npxgettext:2:perl-brace-format", |
96
|
|
|
|
|
|
|
"npxgettext:3:perl-brace-format", |
97
|
|
|
|
|
|
|
"nxgettextp:1:perl-brace-format", |
98
|
|
|
|
|
|
|
"nxgettextp:2:perl-brace-format", |
99
|
|
|
|
|
|
|
]; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub readFile { |
103
|
10
|
|
|
10
|
1
|
6424
|
my ($self, $filename) = @_; |
104
|
|
|
|
|
|
|
|
105
|
10
|
|
|
|
|
51
|
my %options = ( |
106
|
|
|
|
|
|
|
ABSOLUTE => 1, |
107
|
|
|
|
|
|
|
# Needed for reading from POTFILES |
108
|
|
|
|
|
|
|
RELATIVE => 1 |
109
|
|
|
|
|
|
|
); |
110
|
|
|
|
|
|
|
|
111
|
10
|
|
|
|
|
135
|
my $parser = Locale::XGettext::TT2::Parser->new(\%options); |
112
|
|
|
|
|
|
|
|
113
|
10
|
|
|
|
|
2540
|
my $tt = Template->new({ |
114
|
|
|
|
|
|
|
%options, |
115
|
|
|
|
|
|
|
PARSER => $parser, |
116
|
|
|
|
|
|
|
}); |
117
|
|
|
|
|
|
|
|
118
|
10
|
|
|
|
|
167794
|
my $sink; |
119
|
10
|
|
|
|
|
39
|
$parser->{__xgettext} = $self; |
120
|
10
|
|
|
|
|
41
|
$parser->{__xgettext_filename} = $filename; |
121
|
|
|
|
|
|
|
|
122
|
10
|
100
|
|
|
|
64
|
$tt->process($filename, {}, \$sink) or die $tt->error; |
123
|
|
|
|
|
|
|
|
124
|
9
|
|
|
|
|
7459
|
return $self; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
package Locale::XGettext::TT2::Parser; |
128
|
|
|
|
|
|
|
$Locale::XGettext::TT2::Parser::VERSION = '0.8'; |
129
|
7
|
|
|
7
|
|
56
|
use strict; |
|
7
|
|
|
|
|
21
|
|
|
7
|
|
|
|
|
171
|
|
130
|
|
|
|
|
|
|
|
131
|
7
|
|
|
7
|
|
57
|
use Locale::TextDomain qw(Template-Plugin-Gettext); |
|
7
|
|
|
|
|
25
|
|
|
7
|
|
|
|
|
46
|
|
132
|
|
|
|
|
|
|
|
133
|
7
|
|
|
7
|
|
1214
|
use base qw(Template::Parser); |
|
7
|
|
|
|
|
18
|
|
|
7
|
|
|
|
|
4488
|
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub split_text { |
136
|
10
|
|
|
10
|
|
4961
|
my ($self, $text) = @_; |
137
|
|
|
|
|
|
|
|
138
|
10
|
50
|
|
|
|
69
|
my $chunks = $self->SUPER::split_text($text) or return; |
139
|
|
|
|
|
|
|
|
140
|
10
|
|
|
|
|
8028
|
my $keywords = $self->{__xgettext}->keywords; |
141
|
10
|
|
|
|
|
237
|
my $plug_in = $self->{__xgettext}->option('plug_in'); |
142
|
10
|
100
|
|
|
|
101
|
$plug_in = 'Gettext' if !defined $plug_in; |
143
|
|
|
|
|
|
|
|
144
|
10
|
|
|
|
|
24
|
my $ident; |
145
|
10
|
|
|
|
|
26
|
my $lplug_in = length $plug_in; |
146
|
10
|
|
|
|
|
43
|
while (my $chunk = shift @$chunks) { |
147
|
75
|
100
|
|
|
|
180
|
if (!ref $chunk) { |
148
|
37
|
|
|
|
|
77
|
shift @$chunks; |
149
|
37
|
|
|
|
|
131
|
next; |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
38
|
|
|
|
|
97
|
my ($text, $lineno, $tokens) = @$chunk; |
153
|
|
|
|
|
|
|
|
154
|
38
|
50
|
|
|
|
81
|
next if !ref $tokens; |
155
|
|
|
|
|
|
|
|
156
|
38
|
100
|
|
|
|
83
|
if ($lplug_in) { |
157
|
37
|
100
|
66
|
|
|
143
|
if ('USE' eq $tokens->[0] && 'IDENT' eq $tokens->[2]) { |
158
|
9
|
50
|
0
|
|
|
97
|
if ($plug_in eq $tokens->[3] |
|
|
50
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
159
|
|
|
|
|
|
|
&& (4 == @$tokens |
160
|
|
|
|
|
|
|
|| '(' eq $tokens->[4])) { |
161
|
0
|
|
|
|
|
0
|
$ident = $plug_in; |
162
|
|
|
|
|
|
|
} elsif ('ASSIGN' eq $tokens->[4] && 'IDENT' eq $tokens->[6] |
163
|
|
|
|
|
|
|
&& $plug_in eq $tokens->[7]) { |
164
|
9
|
|
|
|
|
23
|
$ident = $tokens->[3]; |
165
|
|
|
|
|
|
|
} |
166
|
9
|
|
|
|
|
41
|
next; |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
28
|
50
|
|
|
|
68
|
next if !defined $ident; |
170
|
|
|
|
|
|
|
} else { |
171
|
1
|
|
|
|
|
2
|
$ident = ''; |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
29
|
|
|
|
|
90
|
for (my $i = 0; $i < @$tokens; $i += 2) { |
175
|
|
|
|
|
|
|
# FIXME! It would be better to copy $tokens into an array |
176
|
|
|
|
|
|
|
# @tokens because we modify the array reference $tokens. |
177
|
|
|
|
|
|
|
# That implies that we iterate over tokens that do ot exist |
178
|
|
|
|
|
|
|
# and that is an unnecessary risk. |
179
|
232
|
100
|
100
|
|
|
1686
|
if ($lplug_in |
|
|
100
|
100
|
|
|
|
|
|
|
100
|
66
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
66
|
|
|
|
|
180
|
|
|
|
|
|
|
&& 'IDENT' eq $tokens->[$i] && $ident eq $tokens->[$i + 1] |
181
|
|
|
|
|
|
|
&& 'DOT' eq $tokens->[$i + 2] && 'IDENT' eq $tokens->[$i + 4] |
182
|
|
|
|
|
|
|
&& exists $keywords->{$tokens->[$i + 5]}) { |
183
|
13
|
|
|
|
|
36
|
my $keyword = $keywords->{$tokens->[$i + 5]}; |
184
|
13
|
|
|
|
|
85
|
$self->__extractEntry($text, $lineno, $keyword, |
185
|
|
|
|
|
|
|
@$tokens[$i + 6 .. $#$tokens]); |
186
|
|
|
|
|
|
|
} elsif ('FILTER' eq $tokens->[$i] |
187
|
|
|
|
|
|
|
&& 'IDENT' eq $tokens->[$i + 2] |
188
|
|
|
|
|
|
|
&& exists $keywords->{$tokens->[$i + 3]}) { |
189
|
12
|
|
|
|
|
30
|
my $keyword = $keywords->{$tokens->[$i + 3]}; |
190
|
|
|
|
|
|
|
# Inject the block contents as the first argument. |
191
|
12
|
100
|
|
|
|
28
|
if ($i) { |
192
|
9
|
|
|
|
|
31
|
my $first_arg; |
193
|
9
|
50
|
|
|
|
30
|
if ($tokens->[$i - 2] eq 'LITERAL') { |
194
|
9
|
|
|
|
|
19
|
$first_arg = $tokens->[$i - 1]; |
195
|
|
|
|
|
|
|
} else { |
196
|
0
|
|
|
|
|
0
|
next; |
197
|
|
|
|
|
|
|
} |
198
|
|
|
|
|
|
|
# May have been called without parentheses, see |
199
|
|
|
|
|
|
|
# https://github.com/gflohr/Template-Plugin-Gettext/issues/4 |
200
|
9
|
100
|
100
|
|
|
68
|
if (!defined $tokens->[4 + $i]) { |
|
|
100
|
|
|
|
|
|
201
|
2
|
|
|
|
|
9
|
$tokens->[4 + $i] = $tokens->[5 + $i] = '('; |
202
|
2
|
|
|
|
|
7
|
$tokens->[6 + $i] = $tokens->[7 + $i] = ')'; |
203
|
2
|
|
|
|
|
9
|
splice @$tokens, 6 + $i, 0, LITERAL => $first_arg; |
204
|
|
|
|
|
|
|
# Or without parentheses and another filter is immediately |
205
|
|
|
|
|
|
|
# following or the value gets dereferenced with a dot. |
206
|
|
|
|
|
|
|
# The latter is kind of nonsense but we support it |
207
|
|
|
|
|
|
|
# elsewhere as well and it is hard to catch. |
208
|
|
|
|
|
|
|
} elsif ('FILTER' eq $tokens->[4 + $i] |
209
|
|
|
|
|
|
|
|| 'DOT' eq $tokens->[4 + $i]) { |
210
|
4
|
|
|
|
|
20
|
splice @$tokens, 4 + $i, 0, |
211
|
|
|
|
|
|
|
'(', '(', LITERAL => $first_arg, ')', ')'; |
212
|
|
|
|
|
|
|
} else { |
213
|
3
|
|
|
|
|
16
|
splice @$tokens, 6 + $i, 0, |
214
|
|
|
|
|
|
|
LITERAL => $first_arg, COMMA => ','; |
215
|
|
|
|
|
|
|
} |
216
|
|
|
|
|
|
|
} else { |
217
|
3
|
50
|
|
|
|
12
|
next if !@$chunks; |
218
|
3
|
|
|
|
|
18
|
my $first_arg; |
219
|
3
|
50
|
|
|
|
17
|
if (ref $chunks->[0]) { |
|
|
50
|
|
|
|
|
|
220
|
0
|
0
|
|
|
|
0
|
next if $chunks->[0]->[2] ne 'ITEXT'; |
221
|
0
|
|
|
|
|
0
|
$first_arg = $chunks->[0]->[0]; |
222
|
|
|
|
|
|
|
} elsif ('TEXT' eq $chunks->[0]) { |
223
|
3
|
|
|
|
|
8
|
$first_arg = $chunks->[1]; |
224
|
|
|
|
|
|
|
} else { |
225
|
0
|
|
|
|
|
0
|
next; |
226
|
|
|
|
|
|
|
} |
227
|
3
|
|
|
|
|
16
|
splice @$tokens, 6, 0, |
228
|
|
|
|
|
|
|
'LITERAL', $first_arg, 'COMMA', ','; |
229
|
|
|
|
|
|
|
} |
230
|
12
|
|
|
|
|
69
|
$self->__extractEntry($text, $lineno, $keyword, |
231
|
|
|
|
|
|
|
@$tokens[$i + 4 .. $#$tokens]); |
232
|
|
|
|
|
|
|
} elsif (!$lplug_in && 'IDENT' eq $tokens->[$i] |
233
|
|
|
|
|
|
|
&& exists $keywords->{$tokens->[$i + 1]}) { |
234
|
1
|
|
|
|
|
4
|
my $keyword = $keywords->{$tokens->[$i + 1]}; |
235
|
1
|
|
|
|
|
7
|
$self->__extractEntry($text, $lineno, $keyword, |
236
|
|
|
|
|
|
|
@$tokens[$i + 2 .. $#$tokens]); |
237
|
|
|
|
|
|
|
} |
238
|
|
|
|
|
|
|
} |
239
|
|
|
|
|
|
|
} |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
# Stop processing here, so that for example includes are ignored. |
242
|
9
|
|
|
|
|
50
|
return []; |
243
|
|
|
|
|
|
|
} |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
sub __extractEntry { |
246
|
26
|
|
|
26
|
|
126
|
my ($self, $text, $lineno, $keyword, @tokens) = @_; |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
my $args = sub { |
249
|
26
|
|
|
26
|
|
93
|
my (@tokens) = @_; |
250
|
|
|
|
|
|
|
|
251
|
26
|
50
|
|
|
|
73
|
return if '(' ne $tokens[0]; |
252
|
|
|
|
|
|
|
|
253
|
26
|
|
|
|
|
53
|
splice @tokens, 0, 2; |
254
|
|
|
|
|
|
|
|
255
|
26
|
|
|
|
|
44
|
my @values; |
256
|
26
|
|
|
|
|
69
|
while (@tokens) { |
257
|
53
|
100
|
|
|
|
170
|
if ('LITERAL' eq $tokens[0]) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
258
|
36
|
|
|
|
|
77
|
my $string = substr $tokens[1], 1, -1; |
259
|
36
|
|
|
|
|
78
|
$string =~ s/\\([\\'])/$1/gs; |
260
|
36
|
|
|
|
|
63
|
push @values, $string; |
261
|
36
|
|
|
|
|
68
|
splice @tokens, 0, 2; |
262
|
|
|
|
|
|
|
} elsif ('"' eq $tokens[0]) { |
263
|
8
|
100
|
66
|
|
|
100
|
if ('TEXT' eq $tokens[2] |
|
|
|
33
|
|
|
|
|
|
|
|
66
|
|
|
|
|
264
|
|
|
|
|
|
|
&& '"' eq $tokens[4] |
265
|
|
|
|
|
|
|
&& ('COMMA' eq $tokens[6] |
266
|
|
|
|
|
|
|
|| ')' eq $tokens[6])) { |
267
|
7
|
|
|
|
|
19
|
push @values, $tokens[3]; |
268
|
7
|
|
|
|
|
15
|
splice @tokens, 6; |
269
|
|
|
|
|
|
|
} else { |
270
|
|
|
|
|
|
|
# String containing interpolated variables. |
271
|
1
|
|
|
|
|
8
|
my $msg = __"Illegal variable interpolation at \"\$\"!"; |
272
|
1
|
|
|
|
|
136
|
push @values, \$msg; |
273
|
1
|
|
|
|
|
4
|
while (@tokens) { |
274
|
10
|
50
|
|
|
|
20
|
last if 'COMMA' eq $tokens[0]; |
275
|
10
|
100
|
|
|
|
16
|
last if ')' eq $tokens[0]; |
276
|
9
|
|
|
|
|
17
|
shift @tokens; |
277
|
|
|
|
|
|
|
} |
278
|
|
|
|
|
|
|
} |
279
|
|
|
|
|
|
|
} elsif ('NUMBER' eq $tokens[0]) { |
280
|
0
|
|
|
|
|
0
|
push @values, $tokens[1]; |
281
|
0
|
|
|
|
|
0
|
splice @tokens, 0, 2; |
282
|
|
|
|
|
|
|
} elsif ('IDENT' eq $tokens[0]) { |
283
|
|
|
|
|
|
|
# We store undef as the value because we cannot use it |
284
|
|
|
|
|
|
|
# anyway. |
285
|
9
|
|
|
|
|
24
|
push @values, undef; |
286
|
9
|
|
|
|
|
17
|
splice @tokens, 0, 2; |
287
|
|
|
|
|
|
|
} elsif ('(' eq $tokens[0]) { |
288
|
0
|
|
|
|
|
0
|
splice @tokens, 0, 2; |
289
|
0
|
|
|
|
|
0
|
my $nested = 1; |
290
|
0
|
|
|
|
|
0
|
while (@tokens) { |
291
|
0
|
0
|
|
|
|
0
|
if ('(' eq $tokens[0]) { |
|
|
0
|
|
|
|
|
|
292
|
0
|
|
|
|
|
0
|
++$nested; |
293
|
0
|
|
|
|
|
0
|
splice @tokens, 0, 2; |
294
|
|
|
|
|
|
|
} elsif (')' eq $tokens[0]) { |
295
|
0
|
|
|
|
|
0
|
--$nested; |
296
|
0
|
|
|
|
|
0
|
splice @tokens, 0, 2; |
297
|
0
|
0
|
|
|
|
0
|
if (!$nested) { |
298
|
0
|
|
|
|
|
0
|
push @values, undef; |
299
|
0
|
|
|
|
|
0
|
last; |
300
|
|
|
|
|
|
|
} |
301
|
|
|
|
|
|
|
} else { |
302
|
0
|
|
|
|
|
0
|
splice @tokens, 0, 2; |
303
|
|
|
|
|
|
|
} |
304
|
|
|
|
|
|
|
} |
305
|
|
|
|
|
|
|
} else { |
306
|
0
|
|
|
|
|
0
|
return @values; |
307
|
|
|
|
|
|
|
} |
308
|
|
|
|
|
|
|
|
309
|
53
|
50
|
|
|
|
124
|
return @values if !@tokens; |
310
|
|
|
|
|
|
|
|
311
|
53
|
|
|
|
|
90
|
my $next = shift @tokens; |
312
|
53
|
100
|
66
|
|
|
175
|
if ('COMMA' eq $next) { |
|
|
100
|
|
|
|
|
|
313
|
18
|
|
|
|
|
27
|
shift @tokens; |
314
|
18
|
|
|
|
|
39
|
next; |
315
|
|
|
|
|
|
|
} elsif ('ASSIGN' eq $next && '=>' eq $tokens[0]) { |
316
|
9
|
|
|
|
|
15
|
shift @tokens; |
317
|
9
|
|
|
|
|
21
|
next; |
318
|
|
|
|
|
|
|
} |
319
|
|
|
|
|
|
|
|
320
|
26
|
|
|
|
|
100
|
return @values; |
321
|
|
|
|
|
|
|
} |
322
|
|
|
|
|
|
|
|
323
|
0
|
|
|
|
|
0
|
return @values; |
324
|
26
|
|
|
|
|
164
|
}; |
325
|
|
|
|
|
|
|
|
326
|
26
|
|
|
|
|
113
|
my $min_args = $keyword->singular; |
327
|
26
|
|
|
|
|
149
|
my %forms = (msgid => $keyword->singular); |
328
|
26
|
50
|
|
|
|
139
|
if ($keyword->plural) { |
329
|
0
|
0
|
|
|
|
0
|
$min_args = $keyword->plural if $keyword->plural > $min_args; |
330
|
0
|
|
|
|
|
0
|
$forms{msgid_plural} = $keyword->plural; |
331
|
|
|
|
|
|
|
} |
332
|
|
|
|
|
|
|
|
333
|
26
|
100
|
|
|
|
150
|
if ($keyword->context) { |
334
|
9
|
100
|
|
|
|
46
|
$min_args = $keyword->context if $keyword->context > $min_args; |
335
|
9
|
|
|
|
|
65
|
$forms{msgctxt} = $keyword->context; |
336
|
|
|
|
|
|
|
} |
337
|
|
|
|
|
|
|
|
338
|
26
|
|
|
|
|
131
|
my @args = $args->(@tokens); |
339
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
# Do we have enough arguments? |
341
|
26
|
50
|
|
|
|
83
|
return if $min_args > @args; |
342
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
my $entry = { |
344
|
|
|
|
|
|
|
keyword => $keyword->{function} |
345
|
26
|
|
|
|
|
89
|
}; |
346
|
26
|
|
|
|
|
91
|
foreach my $prop (keys %forms) { |
347
|
35
|
|
|
|
|
73
|
my $argno = $forms{$prop} - 1; |
348
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
# We are only interested in literal values. Whatever is |
350
|
|
|
|
|
|
|
# undefined is not parsable or not valid. |
351
|
35
|
50
|
|
|
|
96
|
return if !defined $args[$argno]; |
352
|
35
|
100
|
|
|
|
95
|
if (ref $args[$argno]) { |
353
|
1
|
|
|
|
|
3
|
my $filename = $self->{__xgettext_filename}; |
354
|
1
|
50
|
|
|
|
7
|
die "$filename:$lineno: ${$args[$argno]}\n" if ref $args[$argno]; |
|
1
|
|
|
|
|
31
|
|
355
|
|
|
|
|
|
|
} |
356
|
34
|
|
|
|
|
91
|
$entry->{$prop} = $args[$argno]; |
357
|
|
|
|
|
|
|
} |
358
|
|
|
|
|
|
|
|
359
|
25
|
|
|
|
|
98
|
my $reference = $self->{__xgettext_filename} . ':' . $lineno; |
360
|
25
|
|
|
|
|
92
|
$reference =~ s/-[1-9][0-9]*$//; |
361
|
25
|
|
|
|
|
53
|
$entry->{reference} = $reference; |
362
|
|
|
|
|
|
|
|
363
|
25
|
100
|
|
|
|
82
|
if ($text =~ /^#/) { |
364
|
3
|
|
|
|
|
27
|
my $comment = ''; |
365
|
3
|
|
|
|
|
29
|
my @lines = split /\n/, $text; |
366
|
3
|
|
|
|
|
26
|
foreach my $line (@lines) { |
367
|
6
|
100
|
|
|
|
47
|
last if $line !~ s/^[ \t\r\f\013]*#[ \t\r\f\013]?//; |
368
|
|
|
|
|
|
|
|
369
|
3
|
|
|
|
|
14
|
$comment .= $line . "\n"; |
370
|
|
|
|
|
|
|
} |
371
|
3
|
|
|
|
|
11
|
$entry->{automatic} = $comment; |
372
|
|
|
|
|
|
|
} |
373
|
|
|
|
|
|
|
|
374
|
25
|
|
|
|
|
148
|
$self->{__xgettext}->addEntry($entry); |
375
|
|
|
|
|
|
|
|
376
|
25
|
|
|
|
|
8209
|
return $self; |
377
|
|
|
|
|
|
|
} |
378
|
|
|
|
|
|
|
|
379
|
|
|
|
|
|
|
1; |