line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Locale::TextDomain::OO::Extract::Role::File; ## no critic (TidyCode)
|
2
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
2589
|
use strict;
|
|
7
|
|
|
|
|
17
|
|
|
7
|
|
|
|
|
173
|
|
4
|
7
|
|
|
7
|
|
33
|
use warnings;
|
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
149
|
|
5
|
7
|
|
|
7
|
|
1872
|
use Locale::TextDomain::OO::Util::JoinSplitLexiconKeys;
|
|
7
|
|
|
|
|
229722
|
|
|
7
|
|
|
|
|
272
|
|
6
|
7
|
|
|
7
|
|
2095
|
use Locale::Utils::PlaceholderMaketext;
|
|
7
|
|
|
|
|
47606
|
|
|
7
|
|
|
|
|
194
|
|
7
|
7
|
|
|
7
|
|
72
|
use Moo::Role;
|
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
43
|
|
8
|
7
|
|
|
7
|
|
2387
|
use MooX::Types::MooseLike::Base qw(ArrayRef Bool HashRef Str);
|
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
352
|
|
9
|
7
|
|
|
7
|
|
37
|
use namespace::autoclean;
|
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
28
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '2.007';
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has category => (
|
14
|
|
|
|
|
|
|
is => 'rw',
|
15
|
|
|
|
|
|
|
isa => Str,
|
16
|
|
|
|
|
|
|
default => q{},
|
17
|
|
|
|
|
|
|
);
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has domain => (
|
20
|
|
|
|
|
|
|
is => 'rw',
|
21
|
|
|
|
|
|
|
isa => Str,
|
22
|
|
|
|
|
|
|
default => q{},
|
23
|
|
|
|
|
|
|
);
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has project => (
|
26
|
|
|
|
|
|
|
is => 'rw',
|
27
|
|
|
|
|
|
|
isa => sub {
|
28
|
|
|
|
|
|
|
my $value = shift;
|
29
|
|
|
|
|
|
|
defined $value
|
30
|
|
|
|
|
|
|
or return;
|
31
|
|
|
|
|
|
|
Str->($value);
|
32
|
|
|
|
|
|
|
return;
|
33
|
|
|
|
|
|
|
},
|
34
|
|
|
|
|
|
|
);
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
has category_stack => (
|
37
|
|
|
|
|
|
|
is => 'rw',
|
38
|
|
|
|
|
|
|
isa => ArrayRef,
|
39
|
|
|
|
|
|
|
default => sub { [] },
|
40
|
|
|
|
|
|
|
);
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
has domain_stack => (
|
43
|
|
|
|
|
|
|
is => 'rw',
|
44
|
|
|
|
|
|
|
isa => ArrayRef,
|
45
|
|
|
|
|
|
|
default => sub { [] },
|
46
|
|
|
|
|
|
|
);
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
has filename => (
|
49
|
|
|
|
|
|
|
is => 'rw',
|
50
|
|
|
|
|
|
|
isa => Str,
|
51
|
|
|
|
|
|
|
lazy => 1,
|
52
|
|
|
|
|
|
|
default => 'unknown',
|
53
|
|
|
|
|
|
|
clearer => '_clear_filename',
|
54
|
|
|
|
|
|
|
);
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
has lexicon_ref => (
|
57
|
|
|
|
|
|
|
is => 'rw',
|
58
|
|
|
|
|
|
|
isa => HashRef,
|
59
|
|
|
|
|
|
|
lazy => 1,
|
60
|
|
|
|
|
|
|
default => sub { {} },
|
61
|
|
|
|
|
|
|
);
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
has is_maketext_format_gettext => (
|
64
|
|
|
|
|
|
|
is => 'ro',
|
65
|
|
|
|
|
|
|
isa => Bool,
|
66
|
|
|
|
|
|
|
);
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub clear {
|
69
|
0
|
|
|
0
|
1
|
0
|
my $self = shift;
|
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
0
|
$self->category( q{} );
|
72
|
0
|
|
|
|
|
0
|
$self->domain( q{} );
|
73
|
0
|
|
|
|
|
0
|
$self->project(undef);
|
74
|
0
|
|
|
|
|
0
|
$self->category_stack([]);
|
75
|
0
|
|
|
|
|
0
|
$self->domain_stack([]);
|
76
|
0
|
|
|
|
|
0
|
$self->_clear_filename;
|
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
0
|
return;
|
79
|
|
|
|
|
|
|
}
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
my $list_if_length = sub {
|
82
|
|
|
|
|
|
|
my ($item, @list) = @_;
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
defined $item or return;
|
85
|
|
|
|
|
|
|
length $item or return;
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
return @list;
|
88
|
|
|
|
|
|
|
};
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub add_message {
|
91
|
426
|
|
|
426
|
1
|
1233
|
my ($self, $msg_ref) = @_;
|
92
|
|
|
|
|
|
|
|
93
|
426
|
|
|
|
|
1240
|
my $key_util = Locale::TextDomain::OO::Util::JoinSplitLexiconKeys->instance;
|
94
|
426
|
|
33
|
|
|
1815
|
my $format_util
|
95
|
|
|
|
|
|
|
= $self->is_maketext_format_gettext
|
96
|
|
|
|
|
|
|
&& Locale::Utils::PlaceholderMaketext->new;
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# build the lexicon part
|
99
|
|
|
|
|
|
|
my $lexicon_key = $key_util->join_lexicon_key({(
|
100
|
|
|
|
|
|
|
map {
|
101
|
426
|
|
|
|
|
768
|
$_ => $msg_ref->{$_};
|
|
1278
|
|
|
|
|
3020
|
|
102
|
|
|
|
|
|
|
} qw( category domain project )
|
103
|
|
|
|
|
|
|
)});
|
104
|
|
|
|
|
|
|
my $lexicon
|
105
|
426
|
|
100
|
|
|
12161
|
= $self->lexicon_ref->{$lexicon_key}
|
106
|
|
|
|
|
|
|
||= {
|
107
|
|
|
|
|
|
|
q{} => {
|
108
|
|
|
|
|
|
|
msgstr => {
|
109
|
|
|
|
|
|
|
nplurals => 2,
|
110
|
|
|
|
|
|
|
plural => 'n != 1',
|
111
|
|
|
|
|
|
|
}
|
112
|
|
|
|
|
|
|
},
|
113
|
|
|
|
|
|
|
};
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
# build the message part
|
116
|
|
|
|
|
|
|
my $msg_key = $key_util->join_message_key({
|
117
|
|
|
|
|
|
|
$format_util
|
118
|
|
|
|
|
|
|
? (
|
119
|
|
|
|
|
|
|
msgid => $format_util->maketext_to_gettext( $msg_ref->{msgid} ),
|
120
|
|
|
|
|
|
|
(
|
121
|
|
|
|
|
|
|
map {
|
122
|
0
|
|
|
|
|
0
|
$_ => $msg_ref->{$_};
|
123
|
|
|
|
|
|
|
} qw( msgctxt msgid_plural )
|
124
|
|
|
|
|
|
|
),
|
125
|
|
|
|
|
|
|
)
|
126
|
|
|
|
|
|
|
: (
|
127
|
|
|
|
|
|
|
map {
|
128
|
426
|
50
|
|
|
|
3425
|
$_ => $msg_ref->{$_};
|
|
1278
|
|
|
|
|
3111
|
|
129
|
|
|
|
|
|
|
} qw( msgctxt msgid msgid_plural )
|
130
|
|
|
|
|
|
|
)
|
131
|
|
|
|
|
|
|
});
|
132
|
426
|
100
|
|
|
|
12613
|
if ( exists $lexicon->{$msg_key} ) {
|
133
|
282
|
|
|
|
|
773
|
$lexicon->{$msg_key}->{reference}->{ $msg_ref->{reference} } = undef;
|
134
|
282
|
|
|
|
|
994
|
return;
|
135
|
|
|
|
|
|
|
}
|
136
|
|
|
|
|
|
|
$lexicon->{$msg_key} = {
|
137
|
|
|
|
|
|
|
$list_if_length->( $msg_ref->{automatic}, automatic => $msg_ref->{automatic} ),
|
138
|
|
|
|
|
|
|
reference => { $msg_ref->{reference} => undef },
|
139
|
144
|
|
|
|
|
315
|
};
|
140
|
|
|
|
|
|
|
|
141
|
144
|
|
|
|
|
415
|
return;
|
142
|
|
|
|
|
|
|
}
|
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
1;
|
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
__END__
|