line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Locale::TextDomain::OO::Lexicon::Hash; ## no critic (TidyCode)
|
2
|
|
|
|
|
|
|
|
3
|
9
|
|
|
9
|
|
195709
|
use strict;
|
|
9
|
|
|
|
|
41
|
|
|
9
|
|
|
|
|
283
|
|
4
|
9
|
|
|
9
|
|
52
|
use warnings;
|
|
9
|
|
|
|
|
28
|
|
|
9
|
|
|
|
|
271
|
|
5
|
9
|
|
|
9
|
|
55
|
use Carp qw(confess);
|
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
446
|
|
6
|
9
|
|
|
9
|
|
869
|
use Locale::TextDomain::OO::Singleton::Lexicon;
|
|
9
|
|
|
|
|
23
|
|
|
9
|
|
|
|
|
268
|
|
7
|
9
|
|
|
9
|
|
3629
|
use Locale::TextDomain::OO::Util::ExtractHeader;
|
|
9
|
|
|
|
|
38613
|
|
|
9
|
|
|
|
|
285
|
|
8
|
9
|
|
|
9
|
|
974
|
use Locale::TextDomain::OO::Util::JoinSplitLexiconKeys;
|
|
9
|
|
|
|
|
86731
|
|
|
9
|
|
|
|
|
214
|
|
9
|
9
|
|
|
9
|
|
56
|
use Moo;
|
|
9
|
|
|
|
|
30
|
|
|
9
|
|
|
|
|
58
|
|
10
|
9
|
|
|
9
|
|
3106
|
use MooX::StrictConstructor;
|
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
98
|
|
11
|
9
|
|
|
9
|
|
8096
|
use namespace::autoclean;
|
|
9
|
|
|
|
|
40
|
|
|
9
|
|
|
|
|
69
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '1.031';
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
with qw(
|
16
|
|
|
|
|
|
|
Locale::TextDomain::OO::Role::Logger
|
17
|
|
|
|
|
|
|
);
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub lexicon_ref {
|
20
|
9
|
|
|
9
|
1
|
17487
|
my ($self, $hash_lexicon) = @_;
|
21
|
|
|
|
|
|
|
|
22
|
9
|
50
|
|
|
|
49
|
ref $hash_lexicon eq 'HASH'
|
23
|
|
|
|
|
|
|
or confess 'The given lexicon should be a hash reference';
|
24
|
9
|
|
|
|
|
78
|
my $instance = Locale::TextDomain::OO::Singleton::Lexicon->instance;
|
25
|
9
|
50
|
|
|
|
228
|
$self->logger and $instance->logger( $self->logger );
|
26
|
9
|
|
|
|
|
656
|
my $lexicon = $instance->data;
|
27
|
9
|
|
|
|
|
82
|
my $key_util = Locale::TextDomain::OO::Util::JoinSplitLexiconKeys->instance;
|
28
|
9
|
|
|
|
|
49
|
while ( my ($lexicon_key, $lexicon_value) = each %{$hash_lexicon} ) {
|
|
26
|
|
|
|
|
12809
|
|
29
|
18
|
|
|
|
|
42
|
my $header = $lexicon_value->[0];
|
30
|
|
|
|
|
|
|
my $header_msgstr = $header->{msgstr}
|
31
|
18
|
50
|
|
|
|
59
|
or confess 'msgstr of header not found';
|
32
|
18
|
|
|
|
|
102
|
$lexicon_value->[0] = Locale::TextDomain::OO::Util::ExtractHeader
|
33
|
|
|
|
|
|
|
->instance
|
34
|
|
|
|
|
|
|
->extract_header_msgstr($header_msgstr);
|
35
|
18
|
|
|
|
|
2188
|
my $nplurals = $lexicon_value->[0]->{nplurals};
|
36
|
|
|
|
|
|
|
VALUE:
|
37
|
18
|
|
|
|
|
40
|
for my $value ( @{$lexicon_value} ) {
|
|
18
|
|
|
|
|
51
|
|
38
|
|
|
|
|
|
|
# move to lexicon
|
39
|
|
|
|
|
|
|
my $msg_key = $key_util->join_message_key({
|
40
|
|
|
|
|
|
|
msgctxt => delete $value->{msgctxt},
|
41
|
|
|
|
|
|
|
msgid => my $msgid = delete $value->{msgid},
|
42
|
|
|
|
|
|
|
msgid_plural => my $msgid_plural = delete $value->{msgid_plural},
|
43
|
60
|
|
|
|
|
301
|
});
|
44
|
60
|
|
|
|
|
1971
|
$lexicon->{$lexicon_key}->{$msg_key} = $value;
|
45
|
|
|
|
|
|
|
# structure faults
|
46
|
|
|
|
|
|
|
exists $value->{msgstr_plural}
|
47
|
60
|
100
|
|
|
|
189
|
or next VALUE;
|
48
|
13
|
|
|
|
|
20
|
my $plural_count = @{ $value->{msgstr_plural} };
|
|
13
|
|
|
|
|
29
|
|
49
|
13
|
50
|
|
|
|
62
|
$plural_count <= $nplurals or confess sprintf
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
50
|
|
|
|
|
|
|
'Count of msgstr_plural=%s but nplurals=%s for msgid="%s" msgid_plural="%s"',
|
51
|
|
|
|
|
|
|
$plural_count,
|
52
|
|
|
|
|
|
|
$nplurals,
|
53
|
|
|
|
|
|
|
( defined $msgid ? $msgid : q{} ),
|
54
|
|
|
|
|
|
|
( defined $msgid_plural ? $msgid_plural : q{} );
|
55
|
|
|
|
|
|
|
}
|
56
|
|
|
|
|
|
|
$self->logger
|
57
|
17
|
50
|
|
|
|
380
|
and $self->logger->(
|
58
|
|
|
|
|
|
|
qq{Lexicon "$lexicon_key" loaded from hash.},
|
59
|
|
|
|
|
|
|
{
|
60
|
|
|
|
|
|
|
object => $self,
|
61
|
|
|
|
|
|
|
type => 'debug',
|
62
|
|
|
|
|
|
|
event => 'lexicon,load',
|
63
|
|
|
|
|
|
|
},
|
64
|
|
|
|
|
|
|
);
|
65
|
|
|
|
|
|
|
}
|
66
|
|
|
|
|
|
|
|
67
|
8
|
|
|
|
|
43
|
return $self;
|
68
|
|
|
|
|
|
|
}
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1;
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
__END__
|