| 1 | package Locale::TextDomain::OO::Extract::Process::Plugin::PO; ## no critic (TidyCode) | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Carp qw(confess); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Encode qw(find_encoding); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Locale::PO; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Locale::TextDomain::OO::Util::ExtractHeader; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Locale::TextDomain::OO::Util::JoinSplitLexiconKeys; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Moo; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use MooX::StrictConstructor; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use MooX::Types::MooseLike::Base qw(HashRef Str); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||
| 15 | 1 | our $VERSION = '2.007'; | |||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||
| 17 | 1 | has category => ( | |||||||||||||||||||||||||||||||
| 18 | is => 'rw', | ||||||||||||||||||||||||||||||||
| 19 | isa => Str, | ||||||||||||||||||||||||||||||||
| 20 | lazy => 1, | ||||||||||||||||||||||||||||||||
| 21 | default => q{}, | ||||||||||||||||||||||||||||||||
| 22 | ); | ||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||
| 24 | 1 | has domain => ( | |||||||||||||||||||||||||||||||
| 25 | is => 'rw', | ||||||||||||||||||||||||||||||||
| 26 | isa => Str, | ||||||||||||||||||||||||||||||||
| 27 | lazy => 1, | ||||||||||||||||||||||||||||||||
| 28 | default => q{}, | ||||||||||||||||||||||||||||||||
| 29 | ); | ||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||
| 31 | 1 | has language => ( | |||||||||||||||||||||||||||||||
| 32 | is => 'rw', | ||||||||||||||||||||||||||||||||
| 33 | isa => Str, | ||||||||||||||||||||||||||||||||
| 34 | lazy => 1, | ||||||||||||||||||||||||||||||||
| 35 | default => 'i-default', | ||||||||||||||||||||||||||||||||
| 36 | ); | ||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||
| 38 | has project => ( | ||||||||||||||||||||||||||||||||
| 39 | is => 'rw', | ||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | isa => sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||
| 41 | 0 | my $project = shift; | |||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | defined $project | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 43 | or return; | ||||||||||||||||||||||||||||||||
| 44 | 0 | return Str->($project); | |||||||||||||||||||||||||||||||
| 45 | }, | ||||||||||||||||||||||||||||||||
| 46 | 1 | ); | |||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||
| 48 | has lexicon_ref => ( | ||||||||||||||||||||||||||||||||
| 49 | is => 'rw', | ||||||||||||||||||||||||||||||||
| 50 | isa => HashRef, | ||||||||||||||||||||||||||||||||
| 51 | lazy => 1, | ||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | default => sub { {} }, | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 53 | 1 | ); | |||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | sub clear { | ||||||||||||||||||||||||||||||
|
Subroutine
clear: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 56 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||
| 58 | 0 | $self->category( q{} ); | |||||||||||||||||||||||||||||||
| 59 | 0 | $self->domain( q{} ); | |||||||||||||||||||||||||||||||
| 60 | 0 | $self->language('i-default'); | |||||||||||||||||||||||||||||||
| 61 | 0 | $self->project(undef); | |||||||||||||||||||||||||||||||
| 62 | 0 | $self->lexicon_ref( {} ); | |||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||
| 64 | 0 | return; | |||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | sub slurp { | ||||||||||||||||||||||||||||||
|
Subroutine
slurp: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 68 | 0 | my ( $self, $filename ) = @_; | |||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | defined $filename | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 71 | or confess 'Undef is not a name of a po/pot file'; | ||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | my $pos_ref = Locale::PO->load_file_asarray($filename) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 73 | or confess "$filename is not a valid po/pot file"; | ||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | my $header = Locale::TextDomain::OO::Util::ExtractHeader | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$pos_ref->[0]->msgstr || confess("No header found in file $filename")
MC/DC0%0/1
$pos_ref->[0]->msgstr || confess("No header found in file $filename")
$pos_ref->[0]->msgstr
Truth table0%0/2
A
A= $pos_ref->[0]->msgstr
| |||||||||||||||||||||||||||||||||
| 76 | ->instance | ||||||||||||||||||||||||||||||||
| 77 | ->extract_header_msgstr( | ||||||||||||||||||||||||||||||||
| 78 | Locale::PO->dequote( | ||||||||||||||||||||||||||||||||
| 79 | $pos_ref->[0]->msgstr | ||||||||||||||||||||||||||||||||
| 80 | || confess "No header found in file $filename", | ||||||||||||||||||||||||||||||||
| 81 | ), | ||||||||||||||||||||||||||||||||
| 82 | ); | ||||||||||||||||||||||||||||||||
| 83 | 0 | my $encode_obj = find_encoding( $header->{charset} ); | |||||||||||||||||||||||||||||||
| 84 | 0 | my $nplurals = $header->{nplurals}; | |||||||||||||||||||||||||||||||
| 85 | 0 | my $plural = $header->{plural}; | |||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | my $decode_code = sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||
| 88 | 0 | my $text = shift; | |||||||||||||||||||||||||||||||
| 89 | # | ||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | defined $text | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 91 | or return; | ||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | length $text | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 93 | or return q{}; | ||||||||||||||||||||||||||||||||
| 94 | # | ||||||||||||||||||||||||||||||||
| 95 | 0 | return $encode_obj->decode($text); | |||||||||||||||||||||||||||||||
| 96 | 0 | }; | |||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | my $decode_dequote_code = sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||
| 98 | 0 | my $text = shift; | |||||||||||||||||||||||||||||||
| 99 | # | ||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | defined $text | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 101 | or return; | ||||||||||||||||||||||||||||||||
| 102 | 0 | $text = Locale::PO->dequote($text); | |||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | length $text | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 104 | or return; | ||||||||||||||||||||||||||||||||
| 105 | # | ||||||||||||||||||||||||||||||||
| 106 | 0 | return $encode_obj->decode($text); | |||||||||||||||||||||||||||||||
| 107 | 0 | }; | |||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||
| 109 | 0 | my $index = 0; | |||||||||||||||||||||||||||||||
| 110 | 0 | for my $po ( @{$pos_ref} ) { | |||||||||||||||||||||||||||||||
| 111 | my %entry_of = ( | ||||||||||||||||||||||||||||||||
| 112 | ( | ||||||||||||||||||||||||||||||||
| 113 | $index++ | ||||||||||||||||||||||||||||||||
| 114 | ? () | ||||||||||||||||||||||||||||||||
| 115 | : ( | ||||||||||||||||||||||||||||||||
| 116 | nplurals => $nplurals, | ||||||||||||||||||||||||||||||||
| 117 | plural => $plural, | ||||||||||||||||||||||||||||||||
| 118 | ) | ||||||||||||||||||||||||||||||||
| 119 | ), | ||||||||||||||||||||||||||||||||
| 120 | ( | ||||||||||||||||||||||||||||||||
| 121 | map { ## no critic (ComplexMappings) | ||||||||||||||||||||||||||||||||
| 122 | 0 | my $value = $decode_code->( $po->$_ ); | |||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | defined $value | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 124 | ? ( $_ => $value ) | ||||||||||||||||||||||||||||||||
| 125 | : (); | ||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||
| 127 | qw( automatic comment reference ) | ||||||||||||||||||||||||||||||||
| 128 | ), | ||||||||||||||||||||||||||||||||
| 129 | ( | ||||||||||||||||||||||||||||||||
| 130 | map { ## no critic (ComplexMappings) | ||||||||||||||||||||||||||||||||
| 131 | 0 | my $value = $decode_dequote_code->( $po->$_ ); | |||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | defined $value | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 133 | ? ( $_ => $value ) | ||||||||||||||||||||||||||||||||
| 134 | : (); | ||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||
| 136 | qw( msgctxt msgid msgid_plural ) | ||||||||||||||||||||||||||||||||
| 137 | ), | ||||||||||||||||||||||||||||||||
| 138 | ( | ||||||||||||||||||||||||||||||||
| 139 | defined $po->msgid_plural | ||||||||||||||||||||||||||||||||
| 140 | ? ( | ||||||||||||||||||||||||||||||||
| 141 | msgstr_plural => [ | ||||||||||||||||||||||||||||||||
| 142 | do { | ||||||||||||||||||||||||||||||||
| 143 | 0 | my $msgstr_n = $po->msgstr_n; | |||||||||||||||||||||||||||||||
| 144 | map { | ||||||||||||||||||||||||||||||||
| 145 | 0 | scalar $decode_dequote_code->( $msgstr_n->{$_} ); | |||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||
| 147 | 0 .. ( $nplurals - 1 ); | ||||||||||||||||||||||||||||||||
| 148 | }, | ||||||||||||||||||||||||||||||||
| 149 | ], | ||||||||||||||||||||||||||||||||
| 150 | ) | ||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | : do { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 152 | 0 | my $value = $decode_dequote_code->( $po->msgstr ); | |||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | defined $value | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 154 | ? ( msgstr => $value ) | ||||||||||||||||||||||||||||||||
| 155 | : (); | ||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||
| 157 | ), | ||||||||||||||||||||||||||||||||
| 158 | ); | ||||||||||||||||||||||||||||||||
| 159 | 0 | my $key_util = Locale::TextDomain::OO::Util::JoinSplitLexiconKeys->instance; | |||||||||||||||||||||||||||||||
| 160 | 0 | my $lexicon_key = $key_util->join_lexicon_key({ | |||||||||||||||||||||||||||||||
| 161 | category => $self->category, | ||||||||||||||||||||||||||||||||
| 162 | domain => $self->domain, | ||||||||||||||||||||||||||||||||
| 163 | language => $self->language, | ||||||||||||||||||||||||||||||||
| 164 | project => $self->project, | ||||||||||||||||||||||||||||||||
| 165 | }); | ||||||||||||||||||||||||||||||||
| 166 | 0 | my ( $message_key, $message_value_ref ) | |||||||||||||||||||||||||||||||
| 167 | = $key_util->split_message( \%entry_of ); | ||||||||||||||||||||||||||||||||
| 168 | 0 | $self->lexicon_ref->{$lexicon_key}->{$message_key} = $message_value_ref; | |||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||
| 171 | 0 | return; | |||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | sub default_header { | ||||||||||||||||||||||||||||||
|
Subroutine
default_header: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 175 | 0 | my ( $self, $language ) = @_; | |||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||
| 177 | 0 | return <<"EOT"; | |||||||||||||||||||||||||||||||
| 178 | msgid "" | ||||||||||||||||||||||||||||||||
| 179 | msgstr "" | ||||||||||||||||||||||||||||||||
| 180 | "Project-Id-Version: Default-Project 1.0\\n" | ||||||||||||||||||||||||||||||||
| 181 | "PO-Revision-Date: 2000-01-01T00:00:00Z\\n" | ||||||||||||||||||||||||||||||||
| 182 | "Last-Translator: first and last name <info\@example.com>\\n" | ||||||||||||||||||||||||||||||||
| 183 | "Language-Team: LANGUAGE <LL\@li.org>\\n" | ||||||||||||||||||||||||||||||||
| 184 | "MIME-Version: 1.0\\n" | ||||||||||||||||||||||||||||||||
| 185 | "Content-Type: text/plain; charset=UTF-8\\n" | ||||||||||||||||||||||||||||||||
| 186 | "Content-Transfer-Encoding: 8bit\\n" | ||||||||||||||||||||||||||||||||
| 187 | "Language: $language\\n" | ||||||||||||||||||||||||||||||||
| 188 | "Plural-Forms: nplurals=2; plural=(n != 1);" | ||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||
| 190 | EOT | ||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | sub spew { | ||||||||||||||||||||||||||||||
|
Subroutine
spew: not called CC=15 SCAR=54.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 194 | 0 | my ( $self, $filename ) = @_; | |||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | defined $filename | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 197 | or confess 'Undef is not a name of a po/pot file'; | ||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||
| 199 | 0 | my $key_util = Locale::TextDomain::OO::Util::JoinSplitLexiconKeys->instance; | |||||||||||||||||||||||||||||||
| 200 | 0 | my $lexicon_key = $key_util | |||||||||||||||||||||||||||||||
| 201 | ->instance | ||||||||||||||||||||||||||||||||
| 202 | ->join_lexicon_key({ | ||||||||||||||||||||||||||||||||
| 203 | category => $self->category, | ||||||||||||||||||||||||||||||||
| 204 | domain => $self->domain, | ||||||||||||||||||||||||||||||||
| 205 | language => $self->language, | ||||||||||||||||||||||||||||||||
| 206 | project => $self->project, | ||||||||||||||||||||||||||||||||
| 207 | }); | ||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | my $entries_ref = $self->lexicon_ref->{$lexicon_key} | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 209 | or confess sprintf | ||||||||||||||||||||||||||||||||
| 210 | 'No lexicon found for category "%s", domain "%s", language "%s" and project "%s"', | ||||||||||||||||||||||||||||||||
| 211 | $self->category, | ||||||||||||||||||||||||||||||||
| 212 | $self->domain, | ||||||||||||||||||||||||||||||||
| 213 | $self->language, | ||||||||||||||||||||||||||||||||
| 214 | ( defined $self->project ? $self->project : 'undef' ); | ||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||
| 216 | my $header = Locale::TextDomain::OO::Util::ExtractHeader | ||||||||||||||||||||||||||||||||
| 217 | ->instance | ||||||||||||||||||||||||||||||||
| 218 | ->extract_header_msgstr( | ||||||||||||||||||||||||||||||||
| 219 | $entries_ref->{ q{} }->{msgstr} | ||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | || $self->default_header, | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$entries_ref->{''}{'msgstr'} || $self->default_header
MC/DC0%0/2
$entries_ref->{''}{'msgstr'} || $self->default_header
$entries_ref->{''}{'msgstr'}
$self->default_header
Truth table0%0/3
A || B
A= $entries_ref->{''}{'msgstr'}B= $self->default_header
| |||||||||||||||||||||||||||||||||
| 221 | ) | ||||||||||||||||||||||||||||||||
| 222 | or confess sprintf | ||||||||||||||||||||||||||||||||
| 223 | 'No header found in lexicon of category "%s", domain "%s", language "%s" and project "%s"', | ||||||||||||||||||||||||||||||||
| 224 | $self->category, | ||||||||||||||||||||||||||||||||
| 225 | $self->domain, | ||||||||||||||||||||||||||||||||
| 226 | $self->language, | ||||||||||||||||||||||||||||||||
| 227 | ( defined $self->project ? $self->project : 'undef'); | ||||||||||||||||||||||||||||||||
| 228 | 0 | my $encode_obj = find_encoding( $header->{charset} ); | |||||||||||||||||||||||||||||||
| 229 | 0 | my $nplurals = $header->{nplurals}; | |||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||
| 231 | my @po_data = map { ## no critic (ComplexMappings) | ||||||||||||||||||||||||||||||||
| 232 | 0 | my $entry_ref = $key_util->join_message( $_, $entries_ref->{$_} ); | |||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | if ( defined $entry_ref->{reference} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 234 | 0 | my $reference_regex = qr{ | |||||||||||||||||||||||||||||||
| 235 | \s* | ||||||||||||||||||||||||||||||||
| 236 | ( | ||||||||||||||||||||||||||||||||
| 237 | ( [^:]+ ) | ||||||||||||||||||||||||||||||||
| 238 | [:] | ||||||||||||||||||||||||||||||||
| 239 | ( \d+ ) | ||||||||||||||||||||||||||||||||
| 240 | ) | ||||||||||||||||||||||||||||||||
| 241 | }xms; | ||||||||||||||||||||||||||||||||
| 242 | my @match = ref $entry_ref->{reference} eq 'HASH' | ||||||||||||||||||||||||||||||||
| 243 | ? ( | ||||||||||||||||||||||||||||||||
| 244 | map { | ||||||||||||||||||||||||||||||||
| 245 | 0 | $_ =~ $reference_regex; | |||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||
| 247 | 0 | keys %{ $entry_ref->{reference} } | |||||||||||||||||||||||||||||||
| 248 | ) | ||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | : $entry_ref->{reference} =~ m{ $reference_regex }xmsg; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 250 | 0 | my @references; | |||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | while ( my ( $reference, $name, $line ) = splice @match, 0, 3 ) { ## no critic (MagicNumbers) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 252 | 0 | push @references, [ $reference, $name, $line ]; | |||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||
| 254 | $entry_ref->{reference} = join "\n", | ||||||||||||||||||||||||||||||||
| 255 | 0 | map { $_->[0] } | |||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | sort { $a->[1] cmp $b->[1] || $a->[2] <=> $b->[2] } | ||||||||||||||||||||||||||||||
|
Condition0%0/3
$Locale::TextDomain::OO::Extract::Process::Plugin::PO::a->[1] cmp $Locale::TextDomain::OO::Extract::Process::Plugin::PO::b->[1] || $Locale::TextDomain::OO::Extract::Process::Plugin::PO::a->[2] <=> $Locale::TextDomain::OO::Extract::Process::Plugin::PO::b->[2]
MC/DC0%0/2
$Locale::TextDomain::OO::Extract::Process::Plugin::PO::a->[1] cmp $Locale::TextDomain::OO::Extract::Process::Plugin::PO::b->[1] || $Locale::TextDomain::OO::Extract::Process::Plugin::PO::a->[2] <=> $Locale::TextDomain::OO::Extract::Process::Plugin::PO::b->[2]
$Locale::TextDomain::OO::Extract::Process::Plugin::PO::a->[1] cmp $Locale::TextDomain::OO::Extract::Process::Plugin::PO::b->[1]
$Locale::TextDomain::OO::Extract::Process::Plugin::PO::a->[2] <=> $Locale::TextDomain::OO::Extract::Process::Plugin::PO::b->[2]
Truth table0%0/3
A || B
A= $Locale::TextDomain::OO::Extract::Process::Plugin::PO::a->[1] cmp $Locale::TextDomain::OO::Extract::Process::Plugin::PO::b->[1]B= $Locale::TextDomain::OO::Extract::Process::Plugin::PO::a->[2] <=> $Locale::TextDomain::OO::Extract::Process::Plugin::PO::b->[2]
| |||||||||||||||||||||||||||||||||
| 257 | @references; | ||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||
| 259 | 0 | $entry_ref; | |||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||
| 261 | sort | ||||||||||||||||||||||||||||||||
| 262 | 0 | keys %{$entries_ref}; | |||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | my $encode_code = sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||
| 265 | 0 | my $text = shift; | |||||||||||||||||||||||||||||||
| 266 | # | ||||||||||||||||||||||||||||||||
| 267 | 0 | ▶ | defined $text | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 268 | or return; | ||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | length $text | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 270 | or return q{}; | ||||||||||||||||||||||||||||||||
| 271 | # | ||||||||||||||||||||||||||||||||
| 272 | 0 | return $encode_obj->encode($text); | |||||||||||||||||||||||||||||||
| 273 | 0 | }; | |||||||||||||||||||||||||||||||
| 274 | Locale::PO->save_file_fromarray( | ||||||||||||||||||||||||||||||||
| 275 | $filename, | ||||||||||||||||||||||||||||||||
| 276 | [ | ||||||||||||||||||||||||||||||||
| 277 | map { ## no critic (ComplexMappings) | ||||||||||||||||||||||||||||||||
| 278 | 0 | my $po_data = $_; | |||||||||||||||||||||||||||||||
| 279 | Locale::PO->new( | ||||||||||||||||||||||||||||||||
| 280 | ( | ||||||||||||||||||||||||||||||||
| 281 | map { ## no critic (ComplexMappings) | ||||||||||||||||||||||||||||||||
| 282 | 0 | my $value = $po_data->{$_}; | |||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | defined $value | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 284 | ? ( "-$_" => scalar $encode_code->($value) ) | ||||||||||||||||||||||||||||||||
| 285 | : (); | ||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||
| 287 | qw( automatic comment msgctxt msgid msgid_plural reference ) | ||||||||||||||||||||||||||||||||
| 288 | ), | ||||||||||||||||||||||||||||||||
| 289 | ( | ||||||||||||||||||||||||||||||||
| 290 | defined $po_data->{msgid_plural} | ||||||||||||||||||||||||||||||||
| 291 | ? ( | ||||||||||||||||||||||||||||||||
| 292 | '-msgstr_n' => { | ||||||||||||||||||||||||||||||||
| 293 | map { ## no critic (ComplexMappings) | ||||||||||||||||||||||||||||||||
| 294 | 0 | my $value = $po_data->{msgstr_plural}->[$_]; | |||||||||||||||||||||||||||||||
| 295 | ( | ||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | $_ => scalar $encode_code->( | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 297 | defined $value ? $value : q{}, | ||||||||||||||||||||||||||||||||
| 298 | ), | ||||||||||||||||||||||||||||||||
| 299 | ); | ||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||
| 301 | 0 .. ( $nplurals - 1 ) | ||||||||||||||||||||||||||||||||
| 302 | }, | ||||||||||||||||||||||||||||||||
| 303 | ) | ||||||||||||||||||||||||||||||||
| 304 | : ( | ||||||||||||||||||||||||||||||||
| 305 | '-msgstr' => scalar $encode_code->( | ||||||||||||||||||||||||||||||||
| 306 | defined $po_data->{msgstr} | ||||||||||||||||||||||||||||||||
| 307 | ? $po_data->{msgstr} | ||||||||||||||||||||||||||||||||
| 308 | 0 | : q{} | |||||||||||||||||||||||||||||||
| 309 | ), | ||||||||||||||||||||||||||||||||
| 310 | ) | ||||||||||||||||||||||||||||||||
| 311 | ), | ||||||||||||||||||||||||||||||||
| 312 | ); | ||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||
| 314 | @po_data | ||||||||||||||||||||||||||||||||
| 315 | ], | ||||||||||||||||||||||||||||||||
| 316 | ); | ||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||
| 318 | 0 | return; | |||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||
| 321 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||
| 323 | 1 | 1; | |||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||
| 325 | __END__ | ||||||||||||||||||||||||||||||||