| 1 | package Locale::TextDomain::OO::Plugin::Expand::Gettext::Loc; ## no critic (TidyCode) | ||||||||||||||
| 2 | |||||||||||||||
| 3 | 6 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 6 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | 6 | ▶ | use Locale::Utils::PlaceholderNamed; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | 6 | ▶ | use Moo::Role; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | |||||||||||||||
| 8 | 6 | our $VERSION = '1.027'; | |||||||||||||
| 9 | |||||||||||||||
| 10 | 6 | requires qw( | |||||||||||||
| 11 | translate | ||||||||||||||
| 12 | filter | ||||||||||||||
| 13 | run_filter | ||||||||||||||
| 14 | ); | ||||||||||||||
| 15 | |||||||||||||||
| 16 | has expand_gettext_loc => ( | ||||||||||||||
| 17 | is => 'rw', | ||||||||||||||
| 18 | 5 | ▶ | default => sub { | ||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||
| 19 | 5 | return Locale::Utils::PlaceholderNamed->new; | |||||||||||||
| 20 | }, | ||||||||||||||
| 21 | 6 | ); | |||||||||||||
| 22 | |||||||||||||||
| 23 | 8 | ▶ | sub loc_x { | ||||||||||||
|
Subroutine
loc_x: called CC=4 SCAR=14.5
Pod
documented
| |||||||||||||||
| 24 | 8 | my ($self, $msgid, @args) = @_; | |||||||||||||
| 25 | |||||||||||||||
| 26 | 8 | my $translation = $self->translate(undef, $msgid); | |||||||||||||
| 27 | @args and $translation = $self->expand_gettext_loc->expand_named( | ||||||||||||||
| 28 | $translation, | ||||||||||||||
| 29 | 0 | ▶ | @args == 1 ? %{ $args[0] } : @args, | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 30 | ); | ||||||||||||||
| 31 | 8 | ▶ | $self->filter | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 32 | and $self->run_filter(\$translation); | ||||||||||||||
| 33 | |||||||||||||||
| 34 | 8 | return $translation; | |||||||||||||
| 35 | } | ||||||||||||||
| 36 | |||||||||||||||
| 37 | 4 | ▶ | sub loc_nx { | ||||||||||||
|
Subroutine
loc_nx: called CC=4 SCAR=14.5
Pod
documented
| |||||||||||||||
| 38 | 4 | my ($self, $msgid, $msgid_plural, $count, @args) = @_; | |||||||||||||
| 39 | |||||||||||||||
| 40 | 4 | my $translation = $self->translate(undef, $msgid, $msgid_plural, $count, 1); | |||||||||||||
| 41 | @args and $translation = $self->expand_gettext_loc->expand_named( | ||||||||||||||
| 42 | $translation, | ||||||||||||||
| 43 | 0 | ▶ | @args == 1 ? %{ $args[0] } : @args, | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 44 | ); | ||||||||||||||
| 45 | 4 | ▶ | $self->filter | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 46 | and $self->run_filter(\$translation); | ||||||||||||||
| 47 | |||||||||||||||
| 48 | 4 | return $translation; | |||||||||||||
| 49 | } | ||||||||||||||
| 50 | |||||||||||||||
| 51 | 5 | ▶ | sub loc_px { | ||||||||||||
|
Subroutine
loc_px: called CC=4 SCAR=14.5
Pod
documented
| |||||||||||||||
| 52 | 5 | my ($self, $msgctxt, $msgid, @args) = @_; | |||||||||||||
| 53 | |||||||||||||||
| 54 | 5 | my $translation = $self->translate($msgctxt, $msgid); | |||||||||||||
| 55 | @args and $translation = $self->expand_gettext_loc->expand_named( | ||||||||||||||
| 56 | $translation, | ||||||||||||||
| 57 | 0 | ▶ | @args == 1 ? %{ $args[0] } : @args, | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 58 | ); | ||||||||||||||
| 59 | 5 | ▶ | $self->filter | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 60 | and $self->run_filter(\$translation); | ||||||||||||||
| 61 | |||||||||||||||
| 62 | 5 | return $translation; | |||||||||||||
| 63 | } | ||||||||||||||
| 64 | |||||||||||||||
| 65 | 4 | ▶ | sub loc_npx { ## no critic (ManyArgs) | ||||||||||||
|
Subroutine
loc_npx: called CC=4 SCAR=14.5
Pod
documented
| |||||||||||||||
| 66 | 4 | my ($self, $msgctxt, $msgid, $msgid_plural, $count, @args) = @_; | |||||||||||||
| 67 | |||||||||||||||
| 68 | 4 | my $translation = $self->translate($msgctxt, $msgid, $msgid_plural, $count, 1); | |||||||||||||
| 69 | @args and $translation = $self->expand_gettext_loc->expand_named( | ||||||||||||||
| 70 | $translation, | ||||||||||||||
| 71 | 0 | ▶ | @args == 1 ? %{ $args[0] } : @args, | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 72 | ); | ||||||||||||||
| 73 | 4 | ▶ | $self->filter | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 74 | and $self->run_filter(\$translation); | ||||||||||||||
| 75 | |||||||||||||||
| 76 | 4 | return $translation; | |||||||||||||
| 77 | } | ||||||||||||||
| 78 | |||||||||||||||
| 79 | 6 | ▶ | BEGIN { | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 80 | 6 | ▶ | no warnings qw(redefine); ## no critic (NoWarnings) | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 81 | 6 | *loc_ = \&loc_x; | |||||||||||||
| 82 | 6 | *loc_n = \&loc_nx; | |||||||||||||
| 83 | 6 | *loc_p = \&loc_px; | |||||||||||||
| 84 | 6 | *loc_np = \&loc_npx; | |||||||||||||
| 85 | |||||||||||||||
| 86 | # Dummy methods for string marking. | ||||||||||||||
| 87 | 9 | ▶ | my $dummy = sub { | ||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||
| 88 | 9 | my (undef, @more) = @_; | |||||||||||||
| 89 | 9 | ▶ | return wantarray ? @more : $more[0]; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 90 | 6 | }; | |||||||||||||
| 91 | 6 | *Nloc_ = $dummy; | |||||||||||||
| 92 | 6 | *Nloc_x = $dummy; | |||||||||||||
| 93 | 6 | *Nloc_n = $dummy; | |||||||||||||
| 94 | 6 | *Nloc_nx = $dummy; | |||||||||||||
| 95 | 6 | *Nloc_p = $dummy; | |||||||||||||
| 96 | 6 | *Nloc_px = $dummy; | |||||||||||||
| 97 | 6 | *Nloc_np = $dummy; | |||||||||||||
| 98 | 6 | *Nloc_npx = $dummy; | |||||||||||||
| 99 | } | ||||||||||||||
| 100 | |||||||||||||||
| 101 | 6 | 1; | |||||||||||||
| 102 | |||||||||||||||
| 103 | __END__ | ||||||||||||||