line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Locale::TextDomain::OO::Lexicon::Hash; ## no critic (TidyCode)
|
2
|
|
|
|
|
|
|
|
3
|
9
|
|
|
9
|
|
205875
|
use strict;
|
|
9
|
|
|
|
|
42
|
|
|
9
|
|
|
|
|
275
|
|
4
|
9
|
|
|
9
|
|
47
|
use warnings;
|
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
629
|
|
5
|
9
|
|
|
9
|
|
49
|
use Carp qw(confess);
|
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
475
|
|
6
|
9
|
|
|
9
|
|
927
|
use Locale::TextDomain::OO::Singleton::Lexicon;
|
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
223
|
|
7
|
9
|
|
|
9
|
|
3582
|
use Locale::TextDomain::OO::Util::ExtractHeader;
|
|
9
|
|
|
|
|
37351
|
|
|
9
|
|
|
|
|
266
|
|
8
|
9
|
|
|
9
|
|
994
|
use Locale::TextDomain::OO::Util::JoinSplitLexiconKeys;
|
|
9
|
|
|
|
|
87466
|
|
|
9
|
|
|
|
|
205
|
|
9
|
9
|
|
|
9
|
|
49
|
use Moo;
|
|
9
|
|
|
|
|
20
|
|
|
9
|
|
|
|
|
54
|
|
10
|
9
|
|
|
9
|
|
2906
|
use MooX::StrictConstructor;
|
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
83
|
|
11
|
9
|
|
|
9
|
|
7956
|
use namespace::autoclean;
|
|
9
|
|
|
|
|
35
|
|
|
9
|
|
|
|
|
64
|
|
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
|
16710
|
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
|
|
|
|
|
77
|
my $instance = Locale::TextDomain::OO::Singleton::Lexicon->instance;
|
25
|
9
|
50
|
|
|
|
209
|
$self->logger and $instance->logger( $self->logger );
|
26
|
9
|
|
|
|
|
708
|
my $lexicon = $instance->data;
|
27
|
9
|
|
|
|
|
78
|
my $key_util = Locale::TextDomain::OO::Util::JoinSplitLexiconKeys->instance;
|
28
|
9
|
|
|
|
|
46
|
while ( my ($lexicon_key, $lexicon_value) = each %{$hash_lexicon} ) {
|
|
26
|
|
|
|
|
21068
|
|
29
|
18
|
|
|
|
|
42
|
my $header = $lexicon_value->[0];
|
30
|
|
|
|
|
|
|
my $header_msgstr = $header->{msgstr}
|
31
|
18
|
50
|
|
|
|
60
|
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
|
|
|
|
|
2095
|
my $nplurals = $lexicon_value->[0]->{nplurals};
|
36
|
|
|
|
|
|
|
VALUE:
|
37
|
18
|
|
|
|
|
38
|
for my $value ( @{$lexicon_value} ) {
|
|
18
|
|
|
|
|
53
|
|
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
|
|
|
|
|
321
|
});
|
44
|
60
|
|
|
|
|
1888
|
$lexicon->{$lexicon_key}->{$msg_key} = $value;
|
45
|
|
|
|
|
|
|
# structure faults
|
46
|
|
|
|
|
|
|
exists $value->{msgstr_plural}
|
47
|
60
|
100
|
|
|
|
183
|
or next VALUE;
|
48
|
13
|
|
|
|
|
19
|
my $plural_count = @{ $value->{msgstr_plural} };
|
|
13
|
|
|
|
|
28
|
|
49
|
13
|
50
|
|
|
|
61
|
$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
|
|
|
|
363
|
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
|
|
|
|
|
46
|
return $self;
|
68
|
|
|
|
|
|
|
}
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1;
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
__END__
|