| 1 | package Locale::Maketext::Test; | ||||||||||||||||||||||||||||||||||||||
| 2 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 3 | 7 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||
| 5 | 7 | ▶ | use 5.014; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 6 | 7 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||
| 8 | 7 | ▶ | use Syntax::Keyword::Try; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 9 | 7 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 10 | 7 | ▶ | use Test::MockModule; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 11 | 7 | ▶ | use Locale::Maketext::ManyPluralForms; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||
| 13 | # ABSTRACT: Locale::Maketext::Test | ||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||
| 15 | =encoding UTF-8 | ||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||
| 17 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||
| 19 | Locale::Maketext::Test | ||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||
| 21 | =cut | ||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||
| 23 | 7 | our $VERSION = '0.06'; | |||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||
| 25 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||
| 27 | use Locale::Maketext::Test; | ||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||
| 29 | my $foo = Locale::Maketext::Test->new(directory => '/tmp/locales'); # it will look for files like id.po, ru.po | ||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||
| 31 | ### optional parameters | ||||||||||||||||||||||||||||||||||||||
| 32 | # languages => ['en', 'de'] - to test specific languages in directory, else it will pick all po files in directory | ||||||||||||||||||||||||||||||||||||||
| 33 | # ideally these languages should be as per https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes format | ||||||||||||||||||||||||||||||||||||||
| 34 | # debug => 1 - if you want to check warnings add debug flag else it will output errors only | ||||||||||||||||||||||||||||||||||||||
| 35 | # auto => 1 set only when you want to fallback in case a key is missing from lexicons | ||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||
| 37 | # start test | ||||||||||||||||||||||||||||||||||||||
| 38 | my $response = $foo->testlocales(); | ||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||
| 40 | # no errors or warnings if | ||||||||||||||||||||||||||||||||||||||
| 41 | $response->{status} eq 1; | ||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||
| 43 | # something is wrong when | ||||||||||||||||||||||||||||||||||||||
| 44 | $response->{status} eq 0; | ||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||
| 46 | # check for errors and warnings in case status is 0 | ||||||||||||||||||||||||||||||||||||||
| 47 | $response->{errors} = {id => [qw(error1 error2)], ru => [qw(error1 error2)]}; | ||||||||||||||||||||||||||||||||||||||
| 48 | # warnings are only present when debug is set to 1 | ||||||||||||||||||||||||||||||||||||||
| 49 | $response->{warnings} = {id => [qw(warn1 warn2)], ru => [qw(warn1 warn2)]}; | ||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||
| 51 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||
| 53 | This reads all message ids from the specified PO files and tries to | ||||||||||||||||||||||||||||||||||||||
| 54 | translate them into the destination language. PO files can be specified either | ||||||||||||||||||||||||||||||||||||||
| 55 | as file name (extension .po) or by providing the language. In the latter case | ||||||||||||||||||||||||||||||||||||||
| 56 | the PO file is found in the directory given by the directory option. | ||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||
| 58 | =head2 TYPES OF ERRORS FOUND | ||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||
| 60 | =head3 unknown %func() calls | ||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||
| 62 | Translations can contain function calls in the form of %func(parameters). | ||||||||||||||||||||||||||||||||||||||
| 63 | These functions must be defined in our code. Sometimes translators try | ||||||||||||||||||||||||||||||||||||||
| 64 | to translate the function name which then calls an undefined function. | ||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||
| 66 | =head3 incorrect number of %plural() parameters | ||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||
| 68 | Different languages have different numbers of plural forms. | ||||||||||||||||||||||||||||||||||||||
| 69 | Some, like Malay, don't have any plural forms. Some, like English or French, | ||||||||||||||||||||||||||||||||||||||
| 70 | have just 2 forms, singular and one plural. Others like Arabic or Russian have | ||||||||||||||||||||||||||||||||||||||
| 71 | more forms. Whenever a translator uses the %plural() function, he must specify | ||||||||||||||||||||||||||||||||||||||
| 72 | the correct number of plural forms as parameters. | ||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||
| 74 | =head3 incorrect usage of %d in %plural() parameters | ||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||
| 76 | In some languages, like English or German, singular is applicable only to the | ||||||||||||||||||||||||||||||||||||||
| 77 | quantity of 1. That means the German translator could come up for instance | ||||||||||||||||||||||||||||||||||||||
| 78 | with the following valid %plural call: | ||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||
| 80 | %plural(%5,ein Stein,%d Steine) | ||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||
| 82 | In other languages, like French or Russian, this would be an error. French uses | ||||||||||||||||||||||||||||||||||||||
| 83 | singular also for 0 quantities. So, if the French translator calls: | ||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||
| 85 | %plural(%5,une porte,%d portes) | ||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||
| 87 | and in the actual call the quantity of 0 is passed the output is still "une porte". | ||||||||||||||||||||||||||||||||||||||
| 88 | In Russian the problem is even more critical because singular is used for instance | ||||||||||||||||||||||||||||||||||||||
| 89 | also for the quantity of 121. | ||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||
| 91 | Thus, this test checks if a) the target language is similar to English in having only | ||||||||||||||||||||||||||||||||||||||
| 92 | 2 plural forms, singular and one plural, and in applying singular only to the quantity | ||||||||||||||||||||||||||||||||||||||
| 93 | of 1. If both of these conditions are met %plural calls like the above are allowed. | ||||||||||||||||||||||||||||||||||||||
| 94 | Otherwise, if at least one of the parameters passed to %plural contains a %d, | ||||||||||||||||||||||||||||||||||||||
| 95 | all of the parameters must contain the %d as well. | ||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||
| 97 | That means the following 2 %plural calls are allowed in Russian: | ||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||
| 99 | %plural(%3,%d книга,%d книги,%d книг) | ||||||||||||||||||||||||||||||||||||||
| 100 | %3 %plural(%3,книга,книги,книг) | ||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||
| 102 | while this is forbidden: | ||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||
| 104 | %plural(%3,одна книга,%d книги,%d книг) | ||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||
| 106 | =head1 SUBROUTINES/METHODS | ||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||
| 108 | =head2 debug | ||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||
| 110 | set this if you need to check warnings along with errors | ||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||
| 112 | =cut | ||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||
| 114 | 7 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 115 | 7 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||
| 117 | 7 | has debug => ( | |||||||||||||||||||||||||||||||||||||
| 118 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||
| 119 | isa => 'Bool', | ||||||||||||||||||||||||||||||||||||||
| 120 | default => 0 | ||||||||||||||||||||||||||||||||||||||
| 121 | ); | ||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||
| 123 | =head2 directory | ||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||
| 125 | directory where locales files are located | ||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||
| 127 | =cut | ||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||
| 129 | 7 | has directory => ( | |||||||||||||||||||||||||||||||||||||
| 130 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||
| 131 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||
| 132 | required => 1 | ||||||||||||||||||||||||||||||||||||||
| 133 | ); | ||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||
| 135 | =head2 languages | ||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||
| 137 | language array, set this if you want to test specific language only in specified directory | ||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||
| 139 | =cut | ||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||
| 141 | has languages => ( | ||||||||||||||||||||||||||||||||||||||
| 142 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||
| 143 | isa => 'ArrayRef[Str]', | ||||||||||||||||||||||||||||||||||||||
| 144 | 1 | ▶ | default => sub { [] }); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||
| 146 | =head2 auto | ||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||
| 148 | flag to fallback when a key is missing from lexicons | ||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||
| 150 | # if this is not set then maketext will output errors if | ||||||||||||||||||||||||||||||||||||||
| 151 | # translations is marked as fuzzy or is missing | ||||||||||||||||||||||||||||||||||||||
| 152 | # read more about it here https://metacpan.org/pod/Locale::Maketext::Lexicon | ||||||||||||||||||||||||||||||||||||||
| 153 | Locale::Maketext::Lexicon->import({ _auto => 1 }) | ||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||
| 155 | =cut | ||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||
| 157 | 7 | has auto => ( | |||||||||||||||||||||||||||||||||||||
| 158 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||
| 159 | isa => 'Bool', | ||||||||||||||||||||||||||||||||||||||
| 160 | default => 0 | ||||||||||||||||||||||||||||||||||||||
| 161 | ); | ||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||
| 163 | has _status => ( | ||||||||||||||||||||||||||||||||||||||
| 164 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||
| 165 | isa => 'HashRef', | ||||||||||||||||||||||||||||||||||||||
| 166 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||
| 167 | init_arg => undef, | ||||||||||||||||||||||||||||||||||||||
| 168 | 5 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 169 | { | ||||||||||||||||||||||||||||||||||||||
| 170 | 5 | status => 1, | |||||||||||||||||||||||||||||||||||||
| 171 | errors => {}, | ||||||||||||||||||||||||||||||||||||||
| 172 | warnings => {}}; | ||||||||||||||||||||||||||||||||||||||
| 173 | 7 | }); | |||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||
| 175 | =head2 BUILD | ||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||
| 177 | =cut | ||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||
| 179 | 6 | ▶ | sub BUILD { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 180 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||
| 182 | 6 | ▶ | unless (scalar @{$self->languages}) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 183 | 1 | my @lang = (); | |||||||||||||||||||||||||||||||||||||
| 184 | 1 | ▶ | if (opendir my $dh, $self->directory) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 185 | 1 | ▶ | while (my $dir = readdir($dh)) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 186 | 5 | ▶ | if (my ($x) = ($dir =~ /^(\w+)\.po$/)) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 187 | 3 | push @lang, $x; | |||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||
| 190 | 1 | @lang = sort @lang; | |||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||
| 192 | 1 | $self->languages(\@lang); | |||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||
| 195 | 6 | return Locale::Maketext::ManyPluralForms->import({ | |||||||||||||||||||||||||||||||||||||
| 196 | '_decode' => 1, | ||||||||||||||||||||||||||||||||||||||
| 197 | '_auto' => $self->auto, | ||||||||||||||||||||||||||||||||||||||
| 198 | '*' => ['Gettext' => File::Spec->rel2abs($self->directory) . '/*.po']}); | ||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||
| 201 | =head2 testlocales | ||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||
| 203 | test po files in directory specified | ||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||
| 205 | =cut | ||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||
| 207 | 6 | ▶ | sub testlocales { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
testlocales: called CC=16 SCAR=29.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 208 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||
| 210 | 6 | foreach my $lang (@{$self->languages}) { | |||||||||||||||||||||||||||||||||||||
| 211 | 8 | my $po = $self->_get_po($lang); | |||||||||||||||||||||||||||||||||||||
| 212 | 7 | my $lg = $po->{header}->{language}; | |||||||||||||||||||||||||||||||||||||
| 213 | 7 | my $hnd = Locale::Maketext::ManyPluralForms->get_handle($lg); | |||||||||||||||||||||||||||||||||||||
| 214 | 7 | $hnd->plural(1, 'test %d'); | |||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||
| 216 | 7 | my $plural_sub = $hnd->{_plural}; | |||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||
| 218 | 7 | my $nplurals = 2; # default | |||||||||||||||||||||||||||||||||||||
| 219 | 7 | ▶ | $nplurals = $1 if $po->{header}->{'plural-forms'} =~ /\bnplurals=(\d+);/; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 220 | 7 | my @plural; | |||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||
| 222 | 7 | ▶ | for (my ($i, $j) = (0, $nplurals); $i < 10000 && $j > 0; $i++) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$i < 10000 and $j > 0
MC/DC50%1/2
$i < 10000 and $j > 0
$i < 10000
$j > 0
Truth table66%2/3
A and B
A= $i < 10000B= $j > 0
| |||||||||||||||||||||||||||||||||||||||
| 223 | 13 | my $pos = $plural_sub->($i); | |||||||||||||||||||||||||||||||||||||
| 224 | 13 | ▶ | unless (defined $plural[$pos]) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 225 | 13 | $plural[$pos] = $i; | |||||||||||||||||||||||||||||||||||||
| 226 | 13 | $j--; | |||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||
| 230 | # $lang_plural_is_like_english==1 means the language has exactly 2 plural forms | ||||||||||||||||||||||||||||||||||||||
| 231 | # and singular is applied only to the quantity of 1. That means something like | ||||||||||||||||||||||||||||||||||||||
| 232 | # %plural(%d,ein Stern,%d Sterne) is allowed. In French for instance, singular is | ||||||||||||||||||||||||||||||||||||||
| 233 | # also applied to the quantity of 0. In that case the singular form should also | ||||||||||||||||||||||||||||||||||||||
| 234 | # contain a %d sequence. | ||||||||||||||||||||||||||||||||||||||
| 235 | 7 | my $lang_plural_is_like_english = ($nplurals == 2); | |||||||||||||||||||||||||||||||||||||
| 236 | 7 | ▶ | if ($lang_plural_is_like_english) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 237 | 4 | ▶ | for (my $i = 0; $i <= 100_000; $i++) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 238 | 400004 | ▶ | next if $i == 1; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 239 | 400000 | ▶ | if ($plural_sub->($i) == 0) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 240 | 0 | $lang_plural_is_like_english = 0; | |||||||||||||||||||||||||||||||||||||
| 241 | 0 | last; | |||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||
| 246 | 7 | my $ln; | |||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||
| 248 | 7 | $plural_sub = $hnd->can('plural'); | |||||||||||||||||||||||||||||||||||||
| 249 | 7 | my $mock = Test::MockModule->new(ref($hnd), no_auto => 1); | |||||||||||||||||||||||||||||||||||||
| 250 | $mock->mock( | ||||||||||||||||||||||||||||||||||||||
| 251 | 1 | ▶ | plural => sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=9 SCAR=28.6
| |||||||||||||||||||||||||||||||||||||||
| 252 | # The plural call should provide exactly the number of forms required by the language | ||||||||||||||||||||||||||||||||||||||
| 253 | 1 | ▶ | push @{$self->_status->{errors}->{$lg}}, | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 254 | 1 | $self->_format_message($ln, "\%plural() requires $nplurals parameters for this language (provided: @{[@_ - 2]})") | |||||||||||||||||||||||||||||||||||||
| 255 | unless @_ == $nplurals + 2; | ||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||
| 257 | # %plural() can be used like | ||||||||||||||||||||||||||||||||||||||
| 258 | # | ||||||||||||||||||||||||||||||||||||||
| 259 | # %plural(%3,word,words) | ||||||||||||||||||||||||||||||||||||||
| 260 | # | ||||||||||||||||||||||||||||||||||||||
| 261 | # or like | ||||||||||||||||||||||||||||||||||||||
| 262 | # | ||||||||||||||||||||||||||||||||||||||
| 263 | # %plural(%3,%d word,%d words) | ||||||||||||||||||||||||||||||||||||||
| 264 | # | ||||||||||||||||||||||||||||||||||||||
| 265 | # In the first case we are only looking for the correct plural form | ||||||||||||||||||||||||||||||||||||||
| 266 | # providing the actual quantity elsewhere. | ||||||||||||||||||||||||||||||||||||||
| 267 | # | ||||||||||||||||||||||||||||||||||||||
| 268 | # The code below checks that either all parameters of the current call contain %d | ||||||||||||||||||||||||||||||||||||||
| 269 | # or none of them. That means something like %plural(%15,one word,%d words) is an | ||||||||||||||||||||||||||||||||||||||
| 270 | # error as singular is in many languages also applied to other quantities than 1. | ||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||
| 272 | 1 | my $found_percent_d = 0; | |||||||||||||||||||||||||||||||||||||
| 273 | 1 | my @no_percent_d; | |||||||||||||||||||||||||||||||||||||
| 274 | 1 | ▶ | for (my $i = 2; $i < @_; $i++) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 275 | 2 | ▶ | if ($_[$i] =~ /%d/) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 276 | 2 | $found_percent_d++; | |||||||||||||||||||||||||||||||||||||
| 277 | } else { | ||||||||||||||||||||||||||||||||||||||
| 278 | # $i==2 means it's the singular parameter. This one is allowed to not contain | ||||||||||||||||||||||||||||||||||||||
| 279 | # %d if the language is like English | ||||||||||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | push @no_percent_d, $i - 1 unless ($i == 2 and $lang_plural_is_like_english); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$i == 2 and $lang_plural_is_like_english
MC/DC0%0/2
$i == 2 and $lang_plural_is_like_english
$i == 2
$lang_plural_is_like_english
Truth table0%0/3
A and B
A= $i == 2B= $lang_plural_is_like_english
| |||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||
| 283 | 1 | ▶ | if ($found_percent_d) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 284 | 1 | ▶ | if (@no_percent_d > 1) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 285 | 0 | my $s = join(', ', @no_percent_d[0 .. $#no_percent_d - 1]) . ' and ' . $no_percent_d[-1]; | |||||||||||||||||||||||||||||||||||||
| 286 | 0 | push @{$self->_status->{errors}->{$lg}}, $self->_format_message($ln, "\%plural() parameters $s miss %d"); | |||||||||||||||||||||||||||||||||||||
| 287 | } elsif (@no_percent_d == 1) { | ||||||||||||||||||||||||||||||||||||||
| 288 | 0 | push @{$self->_status->{errors}->{$lg}}, $self->_format_message($ln, "\%plural() parameter $no_percent_d[0] misses %d"); | |||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||
| 292 | 1 | goto $plural_sub; | |||||||||||||||||||||||||||||||||||||
| 293 | 7 | }); | |||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||
| 295 | 7 | for my $test (@{$po->{ids}}) { | |||||||||||||||||||||||||||||||||||||
| 296 | 21 | $ln = $test->[3]; | |||||||||||||||||||||||||||||||||||||
| 297 | 21 | my $i = 0; | |||||||||||||||||||||||||||||||||||||
| 298 | 21 | my $j = 0; | |||||||||||||||||||||||||||||||||||||
| 299 | my @param = map { | ||||||||||||||||||||||||||||||||||||||
| 300 | 29 | $j++; | |||||||||||||||||||||||||||||||||||||
| 301 | 29 | ▶ | push @{$self->_status->{warnings}->{$lg}}, $self->_format_message($ln, "unused parameter \%$j") if (not defined $_ and $self->debug); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not defined $_ and $self->debug
MC/DC100%2/2
not defined $_ and $self->debug
not defined $_
$self->debug
Truth table100%3/3
not(A) and B
A= not defined $_B= $self->debug
| |||||||||||||||||||||||||||||||||||||||
| 302 | 29 | ▶ | defined $_ && $_ eq 'text' ? 'text' . $i++ : 1; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $_ and $_ eq "text"
MC/DC100%2/2
defined $_ and $_ eq "text"
defined $_
$_ eq "text"
Truth table100%3/3
A and B
A= defined $_B= $_ eq "text"
| |||||||||||||||||||||||||||||||||||||||
| 303 | 21 | } @{$test->[1]}; | |||||||||||||||||||||||||||||||||||||
| 304 | try { | ||||||||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | local $SIG{__WARN__} = sub { die $_[0] }; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||
| 306 | 21 | $hnd->maketext($test->[0], @param); | |||||||||||||||||||||||||||||||||||||
| 307 | 21 | } catch ($e) { | |||||||||||||||||||||||||||||||||||||
| 308 | 6 | ▶ | if ($e =~ /Can't locate object method "([^"]+)" via package/) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 309 | 0 | push @{$self->_status->{errors}->{$lg}}, $self->_format_message($ln, "Unknown directive \%$1()"); | |||||||||||||||||||||||||||||||||||||
| 310 | } else { | ||||||||||||||||||||||||||||||||||||||
| 311 | 6 | push @{$self->_status->{errors}->{$lg}}, $self->_format_message($ln, "Unexpected error:\n$e"); | |||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||
| 317 | 5 | return $self->_status; | |||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||
| 320 | =pod | ||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||
| 322 | This returns hash with status, errors and warnings | ||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||
| 324 | { | ||||||||||||||||||||||||||||||||||||||
| 325 | status => 1/0, # 1 is success, 0 failure | ||||||||||||||||||||||||||||||||||||||
| 326 | errors => { id => [error1, error2], ru => [error1, error2] }, | ||||||||||||||||||||||||||||||||||||||
| 327 | warnings => { id => [warn1, warn2] } | ||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||
| 330 | =cut | ||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||
| 332 | 49 | ▶ | sub _cstring { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_cstring: called CC=4 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||
| 333 | 49 | my %map = ( | |||||||||||||||||||||||||||||||||||||
| 334 | 'a' => "\007", | ||||||||||||||||||||||||||||||||||||||
| 335 | 'b' => "\010", | ||||||||||||||||||||||||||||||||||||||
| 336 | 't' => "\011", | ||||||||||||||||||||||||||||||||||||||
| 337 | 'n' => "\012", | ||||||||||||||||||||||||||||||||||||||
| 338 | 'v' => "\013", | ||||||||||||||||||||||||||||||||||||||
| 339 | 'f' => "\014", | ||||||||||||||||||||||||||||||||||||||
| 340 | 'r' => "\015", | ||||||||||||||||||||||||||||||||||||||
| 341 | ); | ||||||||||||||||||||||||||||||||||||||
| 342 | 49 | return $_[0] =~ s/ | |||||||||||||||||||||||||||||||||||||
| 343 | \\ | ||||||||||||||||||||||||||||||||||||||
| 344 | (?: | ||||||||||||||||||||||||||||||||||||||
| 345 | ([0-7]{1,3}) | ||||||||||||||||||||||||||||||||||||||
| 346 | | | ||||||||||||||||||||||||||||||||||||||
| 347 | x([0-9a-fA-F]{1,2}) | ||||||||||||||||||||||||||||||||||||||
| 348 | | | ||||||||||||||||||||||||||||||||||||||
| 349 | ([\\'"?abfvntr]) | ||||||||||||||||||||||||||||||||||||||
| 350 | ) | ||||||||||||||||||||||||||||||||||||||
| 351 | 84 | ▶ | /$1 ? chr(oct($1)) : $2 ? chr(hex($2)) : ($map{$3} || $3)/regx; | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$map{$3} or $3
MC/DC0%0/2
$map{$3} or $3
$map{$3}
$3
Truth table33%1/3
A or B
A= $map{$3}B= $3
| |||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||
| 354 | 21 | ▶ | sub _bstring { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_bstring: called CC=8 SCAR=22.1
| |||||||||||||||||||||||||||||||||||||||
| 355 | 21 | my @params; | |||||||||||||||||||||||||||||||||||||
| 356 | 21 | return $_[0] =~ s! | |||||||||||||||||||||||||||||||||||||
| 357 | (?> # matches %func(%N,parameters...) | ||||||||||||||||||||||||||||||||||||||
| 358 | % | ||||||||||||||||||||||||||||||||||||||
| 359 | (?<func>\w+) | ||||||||||||||||||||||||||||||||||||||
| 360 | \( | ||||||||||||||||||||||||||||||||||||||
| 361 | % | ||||||||||||||||||||||||||||||||||||||
| 362 | (?<p0>[0-9]+) | ||||||||||||||||||||||||||||||||||||||
| 363 | (?<prest>[^\)]*) | ||||||||||||||||||||||||||||||||||||||
| 364 | \) | ||||||||||||||||||||||||||||||||||||||
| 365 | ) | ||||||||||||||||||||||||||||||||||||||
| 366 | | | ||||||||||||||||||||||||||||||||||||||
| 367 | (?> # matches %func(parameters) | ||||||||||||||||||||||||||||||||||||||
| 368 | % | ||||||||||||||||||||||||||||||||||||||
| 369 | (?<simplefunc>\w+) | ||||||||||||||||||||||||||||||||||||||
| 370 | \( | ||||||||||||||||||||||||||||||||||||||
| 371 | (?<simpleparm>[^\)]*) | ||||||||||||||||||||||||||||||||||||||
| 372 | \) | ||||||||||||||||||||||||||||||||||||||
| 373 | ) | ||||||||||||||||||||||||||||||||||||||
| 374 | | # matches %N | ||||||||||||||||||||||||||||||||||||||
| 375 | % | ||||||||||||||||||||||||||||||||||||||
| 376 | (?<simple>[0-9]+) | ||||||||||||||||||||||||||||||||||||||
| 377 | | # [, ] and ~ should be escaped as ~[, ~] and ~~ | ||||||||||||||||||||||||||||||||||||||
| 378 | (?<esc>[\[\]~]) | ||||||||||||||||||||||||||||||||||||||
| 379 | ! | ||||||||||||||||||||||||||||||||||||||
| 380 | 17 | ▶ | if ($+{esc}) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 381 | 0 | "~$+{esc}"; | |||||||||||||||||||||||||||||||||||||
| 382 | } elsif ($+{simplefunc}) { | ||||||||||||||||||||||||||||||||||||||
| 383 | 0 | "[$+{simplefunc},$+{simpleparm}]"; | |||||||||||||||||||||||||||||||||||||
| 384 | } else { | ||||||||||||||||||||||||||||||||||||||
| 385 | 17 | ▶ | my $pos = ($+{func} ? $+{p0} : $+{simple}) - 1; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 386 | 17 | ▶ | $params[$pos] = $+{func} && $+{func} eq 'plural' ? 'plural' : ($params[$pos] // 'text'); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition60%3/5
$+{"func"} and $+{"func"} eq "plural"
$params[$pos] // "text"
MC/DC50%1/2
$+{"func"} and $+{"func"} eq "plural"
$+{"func"}
$+{"func"} eq "plural"
MC/DC0%0/1
$params[$pos] // "text"
$params[$pos]
Truth table66%2/3
A and B
A= $+{"func"}B= $+{"func"} eq "plural"
Truth table50%1/2
A
A= $params[$pos]
| |||||||||||||||||||||||||||||||||||||||
| 387 | 17 | ▶ | $+{func} ? "[$+{func},_$+{p0}$+{prest}]" : "[_$+{simple}]"; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||||||
| 389 | !regx, \@params; | ||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||
| 392 | { | ||||||||||||||||||||||||||||||||||||||
| 393 | 7 | my @stack; | |||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||
| 395 | 242 | ▶ | sub _nextline { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_nextline: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 396 | 242 | ▶ | return pop @stack if @stack; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 397 | 193 | return scalar readline $_[0]; | |||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||
| 400 | 49 | ▶ | sub _unread { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_unread: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 401 | 49 | push @stack, @_; | |||||||||||||||||||||||||||||||||||||
| 402 | 49 | return; | |||||||||||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||
| 406 | 7 | ▶ | sub _get_trans { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_trans: called CC=5 SCAR=16.3
| |||||||||||||||||||||||||||||||||||||||
| 407 | 28 | my $f = shift; | |||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||
| 409 | 28 | ▶ | while (defined(my $l = _nextline($f))) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 410 | 28 | ▶ | if ($l =~ /^\s*msgstr\s*"(.*)"/) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 411 | 28 | my $line = $1; | |||||||||||||||||||||||||||||||||||||
| 412 | 28 | ▶ | while (defined($l = _nextline($f))) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 413 | 105 | ▶ | if ($l =~ /^\s*"(.*)"/) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 414 | 84 | $line .= $1; | |||||||||||||||||||||||||||||||||||||
| 415 | } else { | ||||||||||||||||||||||||||||||||||||||
| 416 | 21 | _unread($l); | |||||||||||||||||||||||||||||||||||||
| 417 | 21 | return _cstring($line); | |||||||||||||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||
| 420 | 7 | return _cstring($line); | |||||||||||||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||||||||||||
| 423 | 0 | return; | |||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||
| 426 | 8 | ▶ | sub _get_po { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_po: called CC=10 SCAR=23.4
| |||||||||||||||||||||||||||||||||||||||
| 427 | 8 | my ($self, $lang, $header_only) = @_; | |||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||
| 429 | 8 | ▶ | unless ($lang =~ /\.po$/) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 430 | 8 | $lang = $self->directory . '/' . $lang . '.po'; | |||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||
| 433 | 8 | my (%header, @ids, $ln); | |||||||||||||||||||||||||||||||||||||
| 434 | 8 | my $first = 1; | |||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||
| 436 | 8 | ▶ | open my $f, '<:encoding(UTF-8)', $lang or die "Cannot open $lang: $!\n"; ## no critic (RequireBriefOpen) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 437 | READ: | ||||||||||||||||||||||||||||||||||||||
| 438 | 7 | ▶ | while (defined(my $l = _nextline($f))) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 439 | 67 | ▶ | if ($l =~ /^\s*msgid\s*"(.*)"/) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 440 | 28 | my $line = $1; | |||||||||||||||||||||||||||||||||||||
| 441 | 28 | $ln = $.; | |||||||||||||||||||||||||||||||||||||
| 442 | 28 | ▶ | while (defined($l = _nextline($f))) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 443 | 28 | ▶ | if ($l =~ /^\s*"(.*)"/) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 444 | 0 | $line .= $1; | |||||||||||||||||||||||||||||||||||||
| 445 | } else { | ||||||||||||||||||||||||||||||||||||||
| 446 | 28 | _unread($l); | |||||||||||||||||||||||||||||||||||||
| 447 | 28 | ▶ | if ($first) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 448 | 7 | undef $first; | |||||||||||||||||||||||||||||||||||||
| 449 | 7 | %header = map { split /\s*:\s*/, lc($_), 2 } split /\n/, _get_trans($f); | |||||||||||||||||||||||||||||||||||||
| 450 | 7 | ▶ | last READ if $header_only; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 451 | } elsif (length $line) { | ||||||||||||||||||||||||||||||||||||||
| 452 | 21 | push @ids, [_bstring(_cstring($line)), _get_trans($f), $ln]; | |||||||||||||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||||||||||||
| 454 | 28 | last; | |||||||||||||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||
| 460 | return { | ||||||||||||||||||||||||||||||||||||||
| 461 | header => \%header, | ||||||||||||||||||||||||||||||||||||||
| 462 | ids => \@ids, | ||||||||||||||||||||||||||||||||||||||
| 463 | lang => $header{language}, | ||||||||||||||||||||||||||||||||||||||
| 464 | 7 | file => $lang, | |||||||||||||||||||||||||||||||||||||
| 465 | }; | ||||||||||||||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||
| 468 | 9 | ▶ | sub _format_message { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_format_message: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 469 | 9 | my ($self, $line, $message) = @_; | |||||||||||||||||||||||||||||||||||||
| 470 | 9 | $self->_status->{status} = 0; | |||||||||||||||||||||||||||||||||||||
| 471 | 9 | return "(line=$line): $message"; | |||||||||||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||
| 474 | 7 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||
| 476 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||
| 478 | Binary.com, C<< <binary at cpan.org> >> | ||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||
| 480 | =head1 BUGS | ||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||
| 482 | Please report any bugs or feature requests to C<bug-locale-maketext-test at rt.cpan.org>, or through | ||||||||||||||||||||||||||||||||||||||
| 483 | the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Locale-Maketext-Test>. I will be notified, and then you'll | ||||||||||||||||||||||||||||||||||||||
| 484 | automatically be notified of progress on your bug as I make changes. | ||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||
| 489 | =head1 SUPPORT | ||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||
| 491 | You can find documentation for this module with the perldoc command. | ||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||
| 493 | perldoc Locale::Maketext::Test | ||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||
| 496 | You can also look for information at: | ||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||
| 498 | =over 4 | ||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||
| 500 | =item * RT: CPAN's request tracker (report bugs here) | ||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||
| 502 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Locale-Maketext-Test> | ||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||
| 504 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||
| 506 | L<http://annocpan.org/dist/Locale-Maketext-Test> | ||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||
| 508 | =item * CPAN Ratings | ||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||
| 510 | L<http://cpanratings.perl.org/d/Locale-Maketext-Test> | ||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||
| 512 | =item * Search CPAN | ||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||
| 514 | L<http://search.cpan.org/dist/Locale-Maketext-Test/> | ||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||
| 516 | =back | ||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||
| 519 | =head1 ACKNOWLEDGEMENTS | ||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||
| 522 | =cut | ||||||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||||||
| 524 | 7 | 1; # End of Locale::Maketext::Test | |||||||||||||||||||||||||||||||||||||