line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Locale::TextDomain::OO::Util::JoinSplitLexiconKeys; ## no critic (TidyCode)
|
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
88852
|
use strict;
|
|
2
|
|
|
|
|
13
|
|
|
2
|
|
|
|
|
60
|
|
4
|
2
|
|
|
2
|
|
10
|
use warnings;
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
54
|
|
5
|
2
|
|
|
2
|
|
834
|
use Locale::TextDomain::OO::Util::Constants;
|
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
78
|
|
6
|
2
|
|
|
2
|
|
16
|
use namespace::autoclean;
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
35
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '4.001';
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub instance {
|
11
|
1
|
|
|
1
|
1
|
95
|
return __PACKAGE__;
|
12
|
|
|
|
|
|
|
}
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub join_lexicon_key {
|
15
|
2
|
|
|
2
|
1
|
12
|
my ( undef, $arg_ref ) = @_;
|
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
|
|
10
|
my $const = Locale::TextDomain::OO::Util::Constants->instance;
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
return join $const->lexicon_key_separator,
|
20
|
|
|
|
|
|
|
(
|
21
|
|
|
|
|
|
|
( defined $arg_ref->{language} && length $arg_ref->{language} )
|
22
|
|
|
|
|
|
|
? $arg_ref->{language}
|
23
|
|
|
|
|
|
|
: 'i-default'
|
24
|
|
|
|
|
|
|
),
|
25
|
|
|
|
|
|
|
( defined $arg_ref->{category} ? $arg_ref->{category} : q{} ),
|
26
|
|
|
|
|
|
|
( defined $arg_ref->{domain} ? $arg_ref->{domain} : q{} ),
|
27
|
2
|
100
|
66
|
|
|
7
|
( defined $arg_ref->{project} ? $arg_ref->{project} : () );
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
28
|
|
|
|
|
|
|
}
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub split_lexicon_key {
|
31
|
3
|
|
|
3
|
1
|
7
|
my ( undef, $lexicon_key ) = @_;
|
32
|
|
|
|
|
|
|
|
33
|
3
|
100
|
|
|
|
24
|
defined $lexicon_key
|
34
|
|
|
|
|
|
|
or return {};
|
35
|
2
|
|
|
|
|
9
|
my $const = Locale::TextDomain::OO::Util::Constants->instance;
|
36
|
2
|
|
|
|
|
6
|
my ( $language, $category, $domain, $project )
|
37
|
|
|
|
|
|
|
= split $const->lexicon_key_separator, $lexicon_key, 4; ## no critic (Magic Numbers)
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
return {(
|
40
|
2
|
100
|
|
|
|
21
|
language => $language,
|
41
|
|
|
|
|
|
|
category => $category,
|
42
|
|
|
|
|
|
|
domain => $domain,
|
43
|
|
|
|
|
|
|
( defined $project ? ( project => $project ) : () ),
|
44
|
|
|
|
|
|
|
)};
|
45
|
|
|
|
|
|
|
}
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
my $length_or_empty_list = sub {
|
48
|
|
|
|
|
|
|
my $item = shift;
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
defined $item or return;
|
51
|
|
|
|
|
|
|
length $item or return;
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
return $item;
|
54
|
|
|
|
|
|
|
};
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub join_message_key {
|
57
|
8
|
|
|
8
|
1
|
2633
|
my ( undef, $arg_ref, $format ) = @_;
|
58
|
|
|
|
|
|
|
|
59
|
8
|
|
|
|
|
32
|
my $const = Locale::TextDomain::OO::Util::Constants->instance;
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
return join $const->msg_key_separator($format),
|
62
|
|
|
|
|
|
|
(
|
63
|
|
|
|
|
|
|
join $const->plural_separator($format),
|
64
|
|
|
|
|
|
|
$length_or_empty_list->( $arg_ref->{msgid} ),
|
65
|
|
|
|
|
|
|
$length_or_empty_list->( $arg_ref->{msgid_plural} ),
|
66
|
|
|
|
|
|
|
),
|
67
|
8
|
|
|
|
|
27
|
$length_or_empty_list->( $arg_ref->{msgctxt} );
|
68
|
|
|
|
|
|
|
}
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub split_message_key {
|
71
|
8
|
|
|
8
|
1
|
25
|
my ( undef, $message_key, $format ) = @_;
|
72
|
|
|
|
|
|
|
|
73
|
8
|
100
|
|
|
|
29
|
defined $message_key
|
74
|
|
|
|
|
|
|
or return {};
|
75
|
6
|
|
|
|
|
23
|
my $const = Locale::TextDomain::OO::Util::Constants->instance;
|
76
|
6
|
|
|
|
|
21
|
my ( $text, $context )
|
77
|
|
|
|
|
|
|
= split $const->msg_key_separator($format), $message_key;
|
78
|
6
|
100
|
|
|
|
23
|
defined $text
|
79
|
|
|
|
|
|
|
or $text = q{};
|
80
|
6
|
|
|
|
|
19
|
my ( $singular, $plural )
|
81
|
|
|
|
|
|
|
= split $const->plural_separator($format), $text;
|
82
|
6
|
100
|
|
|
|
20
|
defined $singular
|
83
|
|
|
|
|
|
|
or $singular = q{};
|
84
|
6
|
100
|
|
12
|
|
32
|
my $list_if_defined = sub { return defined shift() ? @_ : () };
|
|
12
|
|
|
|
|
96
|
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
return {(
|
87
|
6
|
|
|
|
|
20
|
msgid => $singular,
|
88
|
|
|
|
|
|
|
$list_if_defined->( $context, msgctxt => $context ),
|
89
|
|
|
|
|
|
|
$list_if_defined->( $plural, msgid_plural => $plural ),
|
90
|
|
|
|
|
|
|
)};
|
91
|
|
|
|
|
|
|
}
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub join_message {
|
94
|
4
|
|
|
4
|
1
|
3028
|
my ( $self, $message_key, $message_value_ref, $format ) = @_;
|
95
|
|
|
|
|
|
|
|
96
|
4
|
100
|
|
|
|
15
|
defined $message_key
|
97
|
|
|
|
|
|
|
or $message_key = q{};
|
98
|
4
|
100
|
|
|
|
14
|
ref $message_value_ref eq 'HASH'
|
99
|
|
|
|
|
|
|
or $message_value_ref = {};
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
return {(
|
102
|
4
|
|
|
|
|
14
|
%{$message_value_ref},
|
103
|
4
|
|
|
|
|
10
|
%{ $self->split_message_key($message_key, $format) },
|
|
4
|
|
|
|
|
9
|
|
104
|
|
|
|
|
|
|
)};
|
105
|
|
|
|
|
|
|
}
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub split_message {
|
108
|
4
|
|
|
4
|
1
|
13
|
my ( $self, $message, $format ) = @_;
|
109
|
|
|
|
|
|
|
|
110
|
4
|
100
|
|
|
|
14
|
ref $message eq 'HASH'
|
111
|
|
|
|
|
|
|
or $message = {};
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
my $message_key = $self->join_message_key(
|
114
|
|
|
|
|
|
|
{(
|
115
|
|
|
|
|
|
|
map {
|
116
|
4
|
|
|
|
|
13
|
$_ => delete $message->{$_};
|
|
12
|
|
|
|
|
38
|
|
117
|
|
|
|
|
|
|
}
|
118
|
|
|
|
|
|
|
qw( msgctxt msgid msgid_plural )
|
119
|
|
|
|
|
|
|
)},
|
120
|
|
|
|
|
|
|
$format,
|
121
|
|
|
|
|
|
|
);
|
122
|
|
|
|
|
|
|
|
123
|
4
|
|
|
|
|
34
|
return $message_key, $message;
|
124
|
|
|
|
|
|
|
}
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
1;
|
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
__END__
|