| 1 | ##---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | ## PO Files Manipulation - ~/lib/Text/PO/Gettext.pm | ||||||||||||||||||||||||||||||||||||||||||||||
| 3 | ## Version v1.0.1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 4 | ## Copyright(c) 2026 DEGUEST Pte. Ltd. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5 | ## Author: Jacques Deguest <jack@deguest.jp> | ||||||||||||||||||||||||||||||||||||||||||||||
| 6 | ## Created 2021/07/12 | ||||||||||||||||||||||||||||||||||||||||||||||
| 7 | ## Modified 2026/11/17 | ||||||||||||||||||||||||||||||||||||||||||||||
| 8 | ## All rights reserved | ||||||||||||||||||||||||||||||||||||||||||||||
| 9 | ## This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||||||||||||||||||||
| 10 | ## under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||||||
| 11 | ##---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 12 | package Text::PO::Gettext; | ||||||||||||||||||||||||||||||||||||||||||||||
| 13 | BEGIN | ||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 2 | warnings::register_categories( 'Text::PO' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 18 | 2 | ▶ | use parent qw( Module::Generic ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 2 | ▶ | use vars qw( $VERSION $DOMAIN_RE $LOCALE_RE ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 2 | ▶ | use I18N::Langinfo qw( langinfo ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 2 | ▶ | use POSIX (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 2 | ▶ | use Text::PO; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 2 | our $DOMAIN_RE = qr/^[a-z]+(\.[a-zA-Z0-9\_\-]+)*$/; | |||||||||||||||||||||||||||||||||||||||||||||
| 24 | # Taken from Unicode BCP47 via Locale::Unicode | ||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 2 | our $LOCALE_RE = qr/ | |||||||||||||||||||||||||||||||||||||||||||||
| 26 | (?<locale> | ||||||||||||||||||||||||||||||||||||||||||||||
| 27 | (?<locale_lang> | ||||||||||||||||||||||||||||||||||||||||||||||
| 28 | (?: | ||||||||||||||||||||||||||||||||||||||||||||||
| 29 | # "root" is treated as a special Unicode language subtag in the LDML and required in the valid pattern | ||||||||||||||||||||||||||||||||||||||||||||||
| 30 | (?<root>root) | ||||||||||||||||||||||||||||||||||||||||||||||
| 31 | | | ||||||||||||||||||||||||||||||||||||||||||||||
| 32 | (?<language>[a-z]{2}) | ||||||||||||||||||||||||||||||||||||||||||||||
| 33 | | | ||||||||||||||||||||||||||||||||||||||||||||||
| 34 | (?<language3>[a-z]{3}) | ||||||||||||||||||||||||||||||||||||||||||||||
| 35 | ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 36 | # "Up to three optional extended language subtags composed of three letters each, separated by hyphens" | ||||||||||||||||||||||||||||||||||||||||||||||
| 37 | # "There is currently no extended language subtag registered in the Language Subtag Registry without an equivalent and preferred primary language subtag" | ||||||||||||||||||||||||||||||||||||||||||||||
| 38 | (?: | ||||||||||||||||||||||||||||||||||||||||||||||
| 39 | [_-] | ||||||||||||||||||||||||||||||||||||||||||||||
| 40 | (?<extended> | ||||||||||||||||||||||||||||||||||||||||||||||
| 41 | [a-z]{3} | ||||||||||||||||||||||||||||||||||||||||||||||
| 42 | (?:\-[a-z]{3}){0,2} | ||||||||||||||||||||||||||||||||||||||||||||||
| 43 | ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 44 | )? | ||||||||||||||||||||||||||||||||||||||||||||||
| 45 | ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 46 | # ISO 15924 for scripts | ||||||||||||||||||||||||||||||||||||||||||||||
| 47 | (?: | ||||||||||||||||||||||||||||||||||||||||||||||
| 48 | [_-] | ||||||||||||||||||||||||||||||||||||||||||||||
| 49 | (?: | ||||||||||||||||||||||||||||||||||||||||||||||
| 50 | (?<script>[A-Z][a-z]{3}) | ||||||||||||||||||||||||||||||||||||||||||||||
| 51 | | | ||||||||||||||||||||||||||||||||||||||||||||||
| 52 | (?<script>[a-z]{4}) | ||||||||||||||||||||||||||||||||||||||||||||||
| 53 | ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 54 | )? | ||||||||||||||||||||||||||||||||||||||||||||||
| 55 | (?: | ||||||||||||||||||||||||||||||||||||||||||||||
| 56 | (?: | ||||||||||||||||||||||||||||||||||||||||||||||
| 57 | [_-] | ||||||||||||||||||||||||||||||||||||||||||||||
| 58 | (?<territory> | ||||||||||||||||||||||||||||||||||||||||||||||
| 59 | (?<country_code>[A-Z]{2}) | ||||||||||||||||||||||||||||||||||||||||||||||
| 60 | | | ||||||||||||||||||||||||||||||||||||||||||||||
| 61 | # BCP47, section 2.2.4.4: the UN Standard Country or Area Codes for Statistical Use | ||||||||||||||||||||||||||||||||||||||||||||||
| 62 | # We are careful not to catch a following variant starting with a digit. | ||||||||||||||||||||||||||||||||||||||||||||||
| 63 | (?<region>\d{3}(?!\d)) | ||||||||||||||||||||||||||||||||||||||||||||||
| 64 | ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 65 | )? | ||||||||||||||||||||||||||||||||||||||||||||||
| 66 | # "Optional variant subtags, separated by hyphens, each composed of five to eight letters, or of four characters starting with a digit" | ||||||||||||||||||||||||||||||||||||||||||||||
| 67 | # ca-ES-valencia | ||||||||||||||||||||||||||||||||||||||||||||||
| 68 | # country code can be skipped if the variant is limited to a country | ||||||||||||||||||||||||||||||||||||||||||||||
| 69 | # be-tarask | ||||||||||||||||||||||||||||||||||||||||||||||
| 70 | (?: | ||||||||||||||||||||||||||||||||||||||||||||||
| 71 | [_-] | ||||||||||||||||||||||||||||||||||||||||||||||
| 72 | (?<variant> | ||||||||||||||||||||||||||||||||||||||||||||||
| 73 | (?: | ||||||||||||||||||||||||||||||||||||||||||||||
| 74 | (?:[[:alnum:]]{5,8}) | ||||||||||||||||||||||||||||||||||||||||||||||
| 75 | | | ||||||||||||||||||||||||||||||||||||||||||||||
| 76 | (?:\d[[:alnum:]]{3}) | ||||||||||||||||||||||||||||||||||||||||||||||
| 77 | ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 78 | (?: | ||||||||||||||||||||||||||||||||||||||||||||||
| 79 | [_-] | ||||||||||||||||||||||||||||||||||||||||||||||
| 80 | (?: | ||||||||||||||||||||||||||||||||||||||||||||||
| 81 | (?:[[:alnum:]]{5,8}) | ||||||||||||||||||||||||||||||||||||||||||||||
| 82 | | | ||||||||||||||||||||||||||||||||||||||||||||||
| 83 | (?:\d[[:alnum:]]{3}) | ||||||||||||||||||||||||||||||||||||||||||||||
| 84 | ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 85 | )* | ||||||||||||||||||||||||||||||||||||||||||||||
| 86 | ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 87 | )? | ||||||||||||||||||||||||||||||||||||||||||||||
| 88 | )? | ||||||||||||||||||||||||||||||||||||||||||||||
| 89 | (?:\.(?<locale_encoding>[\w-]+))? | ||||||||||||||||||||||||||||||||||||||||||||||
| 90 | ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 91 | /xi; | ||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 2 | our $VERSION = 'v1.0.1'; | |||||||||||||||||||||||||||||||||||||||||||||
| 93 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||
| 98 | sub init | ||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=6 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 2 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 101 | 2 | $self->{category} = 'LC_MESSAGES'; | |||||||||||||||||||||||||||||||||||||||||||||
| 102 | 2 | $self->{domain} = undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 103 | # We also try LANGUAGE because GNU gettext actually only recognise LANGUAGE | ||||||||||||||||||||||||||||||||||||||||||||||
| 104 | # For example: LANGUAGE=fr_FR.utf-8 TEXTDOMAINDIR=./t gettext -d "com.example.api" -s "Bad Request" | ||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 2 | ▶ | $self->{locale} = $ENV{LANG} || $ENV{LANGUAGE}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$ENV{'LANG'} || $ENV{'LANGUAGE'}
MC/DC0%0/2
$ENV{'LANG'} || $ENV{'LANGUAGE'}
$ENV{'LANG'}
$ENV{'LANGUAGE'}
Truth table33%1/3
A || B
A= $ENV{'LANG'}B= $ENV{'LANGUAGE'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 2 | $self->{path} = undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 107 | 2 | $self->{plural} = []; | |||||||||||||||||||||||||||||||||||||||||||||
| 108 | 2 | $self->{use_json} = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 109 | 2 | $self->{_init_strict_use_sub} = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 110 | 2 | $self->{_init_params_order} = [qw( category path domain locale plural use_json )]; | |||||||||||||||||||||||||||||||||||||||||||||
| 111 | 2 | ▶ | $self->SUPER::init( @_ ) || return( $self->pass_error ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 2 | ▶ | if( !defined( $self->{path} ) || !length( $self->{path} ) ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $self->{"path"} and length $self->{"path"}
MC/DC0%0/2
defined $self->{"path"} and length $self->{"path"}
defined $self->{"path"}
length $self->{"path"}
Truth table33%1/3
A and B
A= defined $self->{"path"}B= length $self->{"path"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 113 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | return( $self->error( "No directory path was provided for localisation" ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 2 | ▶ | $self->textdomain( $self->{domain} ) || return( $self->pass_error ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 2 | return( $self ); | |||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||
| 120 | sub addItem | ||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
addItem: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | my( $locale, $key, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | my $hash = $self->getDomainHash(); | |||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | return( $self->error( "No locale was provided." ) ) if( !defined( $locale ) || !length( $locale ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $locale and length $locale
MC/DC0%0/2
defined $locale and length $locale
defined $locale
length $locale
Truth table0%0/3
A and B
A= defined $localeB= length $locale
| |||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | return( $self->error( "No msgid was provided." ) ) if( !defined( $key ) || !length( $key ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $key and length $key
MC/DC0%0/2
defined $key and length $key
defined $key
length $key
Truth table0%0/3
A and B
A= defined $keyB= length $key
| |||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | $locale = $self->locale_unix( $locale ); | |||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | if( !$self->isSupportedLanguage( $locale ) ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 129 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | return( $self->error( "Language requested \"${locale}\" to add item is not supported." ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | $hash->{ $key } = { msgid => $key, msgstr => $value }; | |||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | return( $hash->{ $key } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 12 | ▶ | sub category { return( shift->_set_get_scalar_as_object( 'category', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
category: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||
| 138 | sub charset | ||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
charset: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | warn( "This method charset() is now deprecated." ) if( $self->_is_warnings_enabled( 'Text::PO' ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||
| 144 | sub contentEncoding | ||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
contentEncoding: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | warn( "This method contentEncoding() is now deprecated." ) if( $self->_is_warnings_enabled( 'Text::PO' ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||
| 150 | sub contentType | ||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
contentType: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | warn( "This method contentType() is now deprecated." ) if( $self->_is_warnings_enabled( 'Text::PO' ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||
| 156 | # <https://superuser.com/questions/392439/lang-and-language-environment-variable-in-debian-based-systems> | ||||||||||||||||||||||||||||||||||||||||||||||
| 157 | sub currentLang | ||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
currentLang: called CC=7 SCAR=31.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 1 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 160 | 1 | ▶ | warn( "This method currentLang() is now deprecated." ) if( $self->_is_warnings_enabled( 'Text::PO' ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 1 | ▶ | return( '' ) if( !CORE::exists( $ENV{LANGUAGE} ) && !CORE::exists( $ENV{LANG} ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $ENV{"LANGUAGE"} or exists $ENV{"LANG"}
MC/DC0%0/2
exists $ENV{"LANGUAGE"} or exists $ENV{"LANG"}
exists $ENV{"LANGUAGE"}
exists $ENV{"LANG"}
Truth table33%1/3
A or B
A= exists $ENV{"LANGUAGE"}B= exists $ENV{"LANG"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | return( ( $ENV{LANGUAGE} || $ENV{LANG} ) ? [split( /:/, ( $ENV{LANGUAGE} || $ENV{LANG} ) )]->[0] : '' ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$ENV{"LANGUAGE"} or $ENV{"LANG"}
$ENV{'LANGUAGE'} || $ENV{'LANG'}
MC/DC0%0/2
$ENV{"LANGUAGE"} or $ENV{"LANG"}
$ENV{"LANGUAGE"}
$ENV{"LANG"}
MC/DC0%0/2
$ENV{'LANGUAGE'} || $ENV{'LANG'}
$ENV{'LANGUAGE'}
$ENV{'LANG'}
Truth table0%0/3
A or B
A= $ENV{"LANGUAGE"}B= $ENV{"LANG"}
Truth table0%0/3
A || B
A= $ENV{'LANGUAGE'}B= $ENV{'LANG'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | return( $self->{locale} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 1 | ▶ | sub dgettext { return( shift->dngettext( @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dgettext: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||
| 168 | sub dngettext | ||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 11 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dngettext: called CC=23 SCAR=41.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 11 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 171 | 11 | my $opts = {}; | |||||||||||||||||||||||||||||||||||||||||||||
| 172 | 11 | ▶ | $opts = pop( @_ ) if( ref( $_[-1] ) eq 'HASH' ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 11 | my( $domain, $msgid, $msgidPlural, $count ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 174 | 11 | my $default; | |||||||||||||||||||||||||||||||||||||||||||||
| 175 | my $index; | ||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 11 | my $locale = $self->locale_web; | |||||||||||||||||||||||||||||||||||||||||||||
| 177 | 11 | ▶ | if( !defined( $count ) || $count !~ /^\d+$/ ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $count and $count =~ /^\d+$/
MC/DC50%1/2
defined $count and $count =~ /^\d+$/
defined $count
$count =~ /^\d+$/
Truth table66%2/3
A and B
A= defined $countB= $count =~ /^\d+$/
| |||||||||||||||||||||||||||||||||||||||||||||||
| 178 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 7 | ▶ | $default = $msgidPlural || $msgid; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$msgidPlural || $msgid
MC/DC0%0/2
$msgidPlural || $msgid
$msgidPlural
$msgid
Truth table33%1/3
A || B
A= $msgidPluralB= $msgid
| |||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 11 | ▶ | if( exists( $opts->{locale} ) && length( $opts->{locale} // '' ) ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition20%1/5
exists $opts->{"locale"} and length($opts->{"locale"} // "")
$opts->{"locale"} // ""
MC/DC0%0/2
exists $opts->{"locale"} and length($opts->{"locale"} // "")
exists $opts->{"locale"}
$opts->{"locale"}
Truth table33%1/3
A and B
A= exists $opts->{"locale"}B= $opts->{"locale"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 182 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | warn( "Specifying a locale in dngettext() / gettext() is deprecated." ) if( $self->_is_warnings_enabled( 'Text::PO' ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 11 | my $dict = $self->getDomainHash({ domain => $domain }); | |||||||||||||||||||||||||||||||||||||||||||||
| 186 | 11 | my $plural = $self->plural; | |||||||||||||||||||||||||||||||||||||||||||||
| 187 | 11 | my $def = $dict->{ $msgid }; | |||||||||||||||||||||||||||||||||||||||||||||
| 188 | 11 | ▶ | if( defined( $def ) && length( $def // '' ) ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition40%2/5
defined $def and length($def // "")
$def // ""
MC/DC0%0/2
defined $def and length($def // "")
defined $def
$def
Truth table33%1/3
A and B
A= defined $defB= $def
| |||||||||||||||||||||||||||||||||||||||||||||||
| 189 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 11 | ▶ | if( $plural->length == 0 ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 191 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | $plural = $self->getPlural(); | |||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 11 | ▶ | if( ref( $def ) eq 'ARRAY' ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 195 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 4 | ▶ | if( $self->_is_number( $count ) && | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->_is_number($count) and int $plural->[0] > 0
MC/DC0%0/2
$self->_is_number($count) and int $plural->[0] > 0
$self->_is_number($count)
int $plural->[0] > 0
Truth table33%1/3
A and B
A= $self->_is_number($count)B= int $plural->[0] > 0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 197 | int( $plural->[0] ) > 0 ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 198 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 2 | ▶ | no warnings 'once'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 4 | my $n = $count; | |||||||||||||||||||||||||||||||||||||||||||||
| 201 | 4 | my $expr = $plural->[1]; | |||||||||||||||||||||||||||||||||||||||||||||
| 202 | 4 | $expr =~ s/(?:^|\b)(?<!\$)(n)(?:\b|$)/$n/g; | |||||||||||||||||||||||||||||||||||||||||||||
| 203 | 4 | $index = eval( $expr ); | |||||||||||||||||||||||||||||||||||||||||||||
| 204 | 4 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 205 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | warn( "Warning only: problem evaluating expression '$expr' for locale ", $locale, ": $@" ) if( $self->_is_warnings_enabled( 'Text::PO' ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 208 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 209 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 4 | $index = int( $index ); | |||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 213 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 214 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | $index = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 217 | # return( join( '', @{$def->{msgstr}->[ $index ]} ) || $default ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 4 | ▶ | my $locale_str = ref( $def->[ $index ] ) eq 'ARRAY' ? join( '', @{$def->[ $index ]} ) : $def->[ $index ]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 4 | ▶ | return( Text::PO::String->new( $locale_str => $locale ) ) if( length( "$locale_str" ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | return( Text::PO::String->new( $default => $locale ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 7 | ▶ | return( Text::PO::String->new( $def || $default => $locale ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$def || $default
MC/DC0%0/2
$def || $default
$def
$default
Truth table33%1/3
A || B
A= $defB= $default
| |||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 224 | elsif( !exists( $dict->{ $msgid } ) ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 225 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | ▶ | warn( "No dictionary was found for msgid \"${msgid}\" and domain \"${domain}\" and locale \"", $self->locale_unix, "\"." ) if( $self->_is_warnings_enabled( 'Text::PO' ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | return( Text::PO::String->new( $default => $locale ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||
| 231 | sub domain | ||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 14 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
domain: called CC=5 SCAR=17.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 14 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 234 | 14 | ▶ | if( @_ ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 235 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 2 | my $v = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 237 | 2 | ▶ | if( !$v ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 238 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | return( $self->error( "No domain was provided." ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 241 | elsif( $v !~ /^$DOMAIN_RE$/ ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 242 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | return( $self->error( "Domain provided \"$v\" contains illegal characters." ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 2 | my $caller = [caller(1)]->[3]; | |||||||||||||||||||||||||||||||||||||||||||||
| 246 | # We do not call textdomain upon init, because we need both domain and locale to be set first | ||||||||||||||||||||||||||||||||||||||||||||||
| 247 | # textdomain() is called directly in init() | ||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 2 | ▶ | $self->textdomain( $v ) unless( $caller eq 'Module::Generic::init' ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 2 | $self->{domain} = $v; | |||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 14 | return( $self->_set_get_scalar_as_object( 'domain' ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||
| 254 | sub exists | ||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
exists: called CC=6 SCAR=21.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 1 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 257 | 1 | my $lang = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 258 | 1 | ▶ | warn( "This method exists() is deprecated. The only dictionary version available is the one matching the locale set upon instantiation." ) if( $self->_is_warnings_enabled( 'Text::PO' ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 1 | ▶ | if( !defined( $lang ) ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 260 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | return( $self->error( "No language to check for existence was provided." ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 263 | elsif( !length( $lang ) ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 264 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | return( $self->error( "Language provided to check for existence is null." ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 267 | elsif( $lang !~ /^$LOCALE_RE$/ ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 268 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | return( $self->error( "Unsupported locale format \"${lang}\"." ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 1 | $lang = $self->locale_unix( $lang ); | |||||||||||||||||||||||||||||||||||||||||||||
| 272 | 1 | ▶ | return( lc( $self->locale_unix ) eq lc( $lang ) ? 1 : 0 ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||
| 275 | sub fetchLocale | ||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 3 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fetchLocale: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 3 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 278 | 3 | my $key = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 279 | 3 | ▶ | warn( "fetchLocale() is now deprecated. There is only one locale per instance of this class." ) if( $self->_is_warnings_enabled( 'Text::PO' ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 3 | my $dict = $self->getDomainHash(); | |||||||||||||||||||||||||||||||||||||||||||||
| 281 | 3 | my $locWeb = $self->locale_web; | |||||||||||||||||||||||||||||||||||||||||||||
| 282 | 3 | my $spans = ["<span lang=\"${locWeb}\">" . $self->dngettext( $self->domain, $key ) . '</span>']; | |||||||||||||||||||||||||||||||||||||||||||||
| 283 | 3 | return( $self->new_array( $spans ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 2 | ▶ | sub getDataPath { return( $ENV{TEXTDOMAINDIR} ); } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getDataPath: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||
| 288 | sub getDaysLong | ||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getDaysLong: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 2 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 291 | 2 | my $opts = $self->_get_args_as_hash( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 292 | 2 | my $ref = $self->_get_days( $self->locale ); | |||||||||||||||||||||||||||||||||||||||||||||
| 293 | 2 | my $days = $ref->[1]; | |||||||||||||||||||||||||||||||||||||||||||||
| 294 | 2 | ▶ | if( $opts->{monday_first} ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 295 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 296 | # Move Sunday at the end | ||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 1 | push( @$days, shift( @$days ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 2 | return( $days ); | |||||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||
| 302 | sub getDaysShort | ||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getDaysShort: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 2 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 305 | 2 | my $opts = $self->_get_args_as_hash( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 306 | 2 | my $ref = $self->_get_days( $self->locale ); | |||||||||||||||||||||||||||||||||||||||||||||
| 307 | 2 | my $days = $ref->[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 308 | 2 | ▶ | if( $opts->{monday_first} ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 309 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 310 | # Move Sunday at the end | ||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 1 | push( @$days, shift( @$days ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 2 | return( $days ); | |||||||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||
| 316 | sub getDomainHash | ||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 15 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getDomainHash: called CC=6 SCAR=19.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 15 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 319 | 15 | my $opts = $self->_get_args_as_hash( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 320 | 15 | ▶ | $opts->{domain} //= $self->domain; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$opts->{"domain"} //= $self->domain
MC/DC0%0/2
$opts->{"domain"} //= $self->domain
$opts->{"domain"}
$self->domain
Truth table66%2/3
A //= B
A= $opts->{"domain"}B= $self->domain
| |||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 15 | ▶ | my $class = ref( $self ) || $self; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 15 | ▶ | if( $opts->{locale} ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 323 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 1 | ▶ | warn( "Calling getDomainHash() with a locale is deprecated. The only locale version is the one stored in this object. If you want other locales, you need to instantiate other objects." ) if( $self->_is_warnings_enabled( 'Text::PO' ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 1 | ▶ | if( lc( $self->locale_unix( $opts->{locale} ) ) ne lc( $self->locale_unix ) ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 326 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 15 | my $dict = $self->{_dict}; | |||||||||||||||||||||||||||||||||||||||||||||
| 331 | 15 | return( $dict ); | |||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 2 | ▶ | sub getLangDataPath { return( $ENV{TEXTLOCALEDIR} ); } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getLangDataPath: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||
| 336 | sub getLanguageDict | ||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getLanguageDict: called CC=4 SCAR=15.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 2 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 339 | 2 | my $lang = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 340 | 2 | ▶ | if( defined( $lang ) ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 341 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 2 | ▶ | warn( "Specifying a locale in getLanguageDict() is now deprecated. Only the locale set upon instantiation is used." ) if( $self->_is_warnings_enabled( 'Text::PO' ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 2 | ▶ | if( lc( $self->locale_unix( $lang ) ) ne lc( $self->locale_unix ) ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 345 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | my $dict = $self->getDomainHash(); | |||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | return( $dict ); | |||||||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 1 | ▶ | sub getLocale { return( shift->locale ); } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getLocale: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||
| 354 | sub getLocales | ||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getLocales: called CC=4 SCAR=15.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 1 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 357 | 1 | ▶ | my $key = shift( @_ ) || return( $self->error( "No text provided to get its localised equivalent" ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift @_ || (return $self->error('No text provided to get its localised equivalent'))
MC/DC0%0/1
shift @_ || (return $self->error('No text provided to get its localised equivalent'))
shift @_
Truth table50%1/2
A
A= shift @_
| |||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 1 | ▶ | my $res = $self->fetchLocale( $key ) || return( $self->pass_error ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->fetchLocale($key) || (return $self->pass_error)
MC/DC0%0/1
$self->fetchLocale($key) || (return $self->pass_error)
$self->fetchLocale($key)
Truth table50%1/2
A
A= $self->fetchLocale($key)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 1 | ▶ | if( scalar( @$res ) > 0 ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 360 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 1 | return( join( "\n", @$res ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 363 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 364 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | return( $key ); | |||||||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||
| 369 | sub getLocalesf | ||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getLocalesf: called CC=5 SCAR=16.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 1 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 372 | 1 | ▶ | my $key = shift( @_ ) || return( $self->error( "No text provided to get its localised equivalent" ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift @_ || (return $self->error('No text provided to get its localised equivalent'))
MC/DC0%0/1
shift @_ || (return $self->error('No text provided to get its localised equivalent'))
shift @_
Truth table50%1/2
A
A= shift @_
| |||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 1 | ▶ | my $res = $self->fetchLocale( $key ) || return( $self->pass_error ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->fetchLocale($key) || (return $self->pass_error)
MC/DC0%0/1
$self->fetchLocale($key) || (return $self->pass_error)
$self->fetchLocale($key)
Truth table50%1/2
A
A= $self->fetchLocale($key)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 1 | ▶ | if( scalar( @$res ) > 0 ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 375 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 1 | ▶ | for( my $i = 0; $i < scalar( @$res ); $i++ ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 377 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 1 | $res->[$i] = sprintf( $res->[$i], @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 1 | return( join( "\n", @$res ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 382 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 383 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | return( sprintf( $key, @_ ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||
| 388 | sub getMetaKeys | ||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getMetaKeys: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 391 | # Deprecated, because it forces us to keep in memory the Text::PO object for virtually no gain. | ||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | ▶ | warn( "getMetaKeys() is deprecated." ) if( $self->_is_warnings_enabled( 'Text::PO' ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||
| 395 | sub getMetaValue | ||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getMetaValue: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | ▶ | my $field = shift( @_ ) || return( $self->error( "No meta field provided to get its value." ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift @_ || (return $self->error('No meta field provided to get its value.'))
MC/DC0%0/1
shift @_ || (return $self->error('No meta field provided to get its value.'))
shift @_
Truth table0%0/2
A
A= shift @_
| |||||||||||||||||||||||||||||||||||||||||||||||
| 399 | # Deprecated, because it forces us to keep in memory the Text::PO object for virtually no gain. | ||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | ▶ | warn( "getMetaValue() is deprecated." ) if( $self->_is_warnings_enabled( 'Text::PO' ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||||||
| 403 | sub getMonthsLong | ||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getMonthsLong: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 1 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 406 | 1 | my $ref = $self->_get_months( $self->locale ); | |||||||||||||||||||||||||||||||||||||||||||||
| 407 | 1 | return( $ref->[1] ); | |||||||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||||||
| 410 | sub getMonthsShort | ||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getMonthsShort: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 1 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 413 | 1 | my $ref = $self->_get_months( $self->locale ); | |||||||||||||||||||||||||||||||||||||||||||||
| 414 | 1 | return( $ref->[0] ); | |||||||||||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||||
| 417 | sub getNumericDict | ||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getNumericDict: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 1 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 420 | 1 | my $ref = $self->_get_numeric_dict( $self->locale ); | |||||||||||||||||||||||||||||||||||||||||||||
| 421 | 1 | return( $ref->[0] ); | |||||||||||||||||||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||||||
| 424 | sub getNumericPosixDict | ||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getNumericPosixDict: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 1 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 427 | 1 | my $ref = $self->_get_numeric_dict( $self->locale ); | |||||||||||||||||||||||||||||||||||||||||||||
| 428 | 1 | return( $ref->[1] ); | |||||||||||||||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||||||
| 431 | sub getPlural | ||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getPlural: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 1 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 434 | 1 | return( $self->{_plural} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||||||
| 437 | sub getText | ||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getText: called CC=7 SCAR=27.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 2 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 440 | 2 | my( $key, $lang ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 441 | 2 | ▶ | return( $self->error( "No text to get its localised equivalent was provided." ) ) if( !defined( $key ) || !length( $key ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $key and length $key
MC/DC0%0/2
defined $key and length $key
defined $key
length $key
Truth table33%1/3
A and B
A= defined $keyB= length $key
| |||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 2 | ▶ | if( defined( $lang ) && CORE::length( $lang // '' ) ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition20%1/5
defined $lang and length($lang // "")
$lang // ""
MC/DC0%0/2
defined $lang and length($lang // "")
defined $lang
$lang
Truth table33%1/3
A and B
A= defined $langB= $lang
| |||||||||||||||||||||||||||||||||||||||||||||||
| 443 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | ▶ | warn( "Specifying a locale is deprecated for getText()" ) if( $self->_is_warnings_enabled( 'Text::PO' ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 445 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 2 | return( $self->dngettext( $self->domain, $key ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 447 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||||||
| 449 | sub getTextf | ||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getTextf: called CC=7 SCAR=25.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 1 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 452 | 1 | my $opts = {}; | |||||||||||||||||||||||||||||||||||||||||||||
| 453 | 1 | ▶ | $opts = pop( @_ ) if( ref( $_[-1] ) eq 'HASH' ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 454 | # $opts->{lang} = $self->locale || $self->currentLang(); | ||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 1 | ▶ | if( CORE::exists( $opts->{lang} ) && | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition25%2/8
exists $opts->{"lang"} and defined $opts->{"lang"} and length($opts->{"lang"} // "")
exists $opts->{"lang"} and defined $opts->{"lang"}
$opts->{"lang"} // ""
MC/DC0%0/3
exists $opts->{"lang"} and defined $opts->{"lang"} and length($opts->{"lang"} // "")
exists $opts->{"lang"}
defined $opts->{"lang"}
$opts->{"lang"}
Truth table25%1/4
A and B and C
A= exists $opts->{"lang"}B= defined $opts->{"lang"}C= $opts->{"lang"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 456 | defined( $opts->{lang} ) && | ||||||||||||||||||||||||||||||||||||||||||||||
| 457 | CORE::length( $opts->{lang} // '' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 458 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | ▶ | warn( "Specifying a locale is deprecated for getTextf()" ) if( $self->_is_warnings_enabled( 'Text::PO' ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 460 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 1 | my $key = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 462 | 1 | my $text = $self->getText( $key ); | |||||||||||||||||||||||||||||||||||||||||||||
| 463 | # We retrieve the locale from the Text::PO::String object | ||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 1 | my $locale = $text->locale; | |||||||||||||||||||||||||||||||||||||||||||||
| 465 | 1 | return( Text::PO::String->new( sprintf( $text, map( "$_", @_ ) ) => $locale ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||||||
| 468 | sub gettext | ||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gettext: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 1 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 471 | 1 | return( $self->dngettext( $self->domain, shift( @_ ) ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | ▶ | sub gettextf { return( shift->getTextf( @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gettextf: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||||||
| 476 | sub isSupportedLanguage | ||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
isSupportedLanguage: called CC=5 SCAR=17.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 1 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 479 | 1 | ▶ | my $lang = shift( @_ ) || return(0); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift @_ || (return 0)
MC/DC0%0/1
shift @_ || (return 0)
shift @_
Truth table50%1/2
A
A= shift @_
| |||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 1 | ▶ | my $class = ref( $self ) || $self; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 1 | $lang = $self->locale_unix( $lang ); | |||||||||||||||||||||||||||||||||||||||||||||
| 482 | 1 | ▶ | warn( "isSupportedLanguage() is now deprecated since there is only 1 supported language: the one you provided upon object instantiation." ) if( $self->_is_warnings_enabled( 'Text::PO' ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 1 | ▶ | return( lc( $lang ) eq lc( $self->locale_unix ) ? 1 : 0 ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 484 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||||||
| 486 | sub language | ||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
language: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | ▶ | warn( "This method language() is now deprecated." ) if( $self->_is_warnings_enabled( 'Text::PO' ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||||||
| 492 | sub languageTeam | ||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
languageTeam: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | ▶ | warn( "This method languageTeam() is now deprecated." ) if( $self->_is_warnings_enabled( 'Text::PO' ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||||||
| 498 | sub lastTranslator | ||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lastTranslator: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | ▶ | warn( "This method lastTranslator() is now deprecated." ) if( $self->_is_warnings_enabled( 'Text::PO' ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 502 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||||||
| 504 | sub mimeVersion | ||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mimeVersion: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | ▶ | warn( "This method mimeVersion() is now deprecated." ) if( $self->_is_warnings_enabled( 'Text::PO' ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 508 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||||||
| 510 | sub locale | ||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 36 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
locale: called CC=8 SCAR=22.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 36 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 513 | 36 | ▶ | if( @_ ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 514 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 2 | my $v = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 516 | 2 | ▶ | if( !defined( $v ) || !length( $v ) ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
defined $v && length $v
MC/DC0%0/2
defined $v && length $v
defined $v
length $v
Truth table33%1/3
A && B
A= defined $vB= length $v
| |||||||||||||||||||||||||||||||||||||||||||||||
| 517 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | return( $self->error( "No language was set." ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 519 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 520 | elsif( $v =~ /^$LOCALE_RE$/ ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 521 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 522 | # The user is responsible for the locale value s/he provides. We only checks s/he provides a valid locale. | ||||||||||||||||||||||||||||||||||||||||||||||
| 523 | # We normalise it. | ||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 2 | my( $loc, $enc ) = split( /\./, $v, 2 ); | |||||||||||||||||||||||||||||||||||||||||||||
| 525 | 2 | $loc =~ tr/-/_/; | |||||||||||||||||||||||||||||||||||||||||||||
| 526 | 2 | $v = $loc; | |||||||||||||||||||||||||||||||||||||||||||||
| 527 | 2 | ▶ | $v .= '.' . $enc if( defined( $enc ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 528 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 529 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 530 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | return( $self->error( "Language provided (\"$v\") is in an unsupported format. Use something like \"en_GB\", \"en-GB\" or simply \"en\" or even \"en_GB.utf-8\"." ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 532 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 2 | ▶ | return( $self->error( "No domain is set or it has disappeared!" ) ) if( !$self->{domain} ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 2 | $self->{locale} = $v; | |||||||||||||||||||||||||||||||||||||||||||||
| 535 | 2 | my $caller = [caller(1)]->[3]; | |||||||||||||||||||||||||||||||||||||||||||||
| 536 | # We do not call textdomain upon init, because we need both domain and locale to be set first | ||||||||||||||||||||||||||||||||||||||||||||||
| 537 | # textdomain() is called directly in init() | ||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 2 | ▶ | $self->textdomain( $self->{domain} ) unless( $caller eq 'Module::Generic::init' ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 539 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 36 | return( $self->_set_get_scalar_as_object( 'locale' ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 541 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||||||
| 543 | sub locale_unix | ||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 16 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
locale_unix: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 16 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 546 | 16 | ▶ | my $loc = shift( @_ ) || $self->locale; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
shift @_ || $self->locale
MC/DC0%0/2
shift @_ || $self->locale
shift @_
$self->locale
Truth table66%2/3
A || B
A= shift @_B= $self->locale
| |||||||||||||||||||||||||||||||||||||||||||||||
| 547 | # Only once | ||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 16 | ▶ | if( $loc =~ /^$LOCALE_RE$/ ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 549 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 16 | ( $loc, my $enc ) = split( /\./, $loc, 2 ); | |||||||||||||||||||||||||||||||||||||||||||||
| 551 | 16 | $loc =~ tr/-/_/; | |||||||||||||||||||||||||||||||||||||||||||||
| 552 | 16 | ▶ | $loc .= '.' . $enc if( defined( $enc ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 553 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 16 | return( $loc ); | |||||||||||||||||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||||||
| 557 | sub locale_web | ||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 18 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
locale_web: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 18 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 560 | 18 | ▶ | my $loc = shift( @_ ) || $self->locale; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
shift @_ || $self->locale
MC/DC0%0/2
shift @_ || $self->locale
shift @_
$self->locale
Truth table66%2/3
A || B
A= shift @_B= $self->locale
| |||||||||||||||||||||||||||||||||||||||||||||||
| 561 | # Only once | ||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 18 | ▶ | if( $loc =~ /^$LOCALE_RE$/ ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 563 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 18 | ( $loc, my $enc ) = split( /\./, $loc, 2 ); | |||||||||||||||||||||||||||||||||||||||||||||
| 565 | 18 | $loc =~ tr/_/-/; | |||||||||||||||||||||||||||||||||||||||||||||
| 566 | 18 | ▶ | $loc .= '.' . $enc if( defined( $enc ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 567 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 18 | return( $loc ); | |||||||||||||||||||||||||||||||||||||||||||||
| 569 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||||||
| 571 | sub ngettext | ||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ngettext: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 2 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 574 | 2 | my( $msgid, $msgidPlural, $count ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 575 | 2 | return( $self->dngettext( $self->domain, $msgid, $msgidPlural, $count ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 576 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 5 | ▶ | sub path { return( shift->_set_get_file( 'path', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
path: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||||||||||||||||
| 580 | sub plural | ||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 12 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
plural: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 12 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 583 | 12 | ▶ | if( @_ ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 584 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | return( $self->_set_get_array_as_object( 'plural', @_ ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 586 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 587 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 588 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 12 | ▶ | if( !scalar( @{$self->{plural}} ) ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 590 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 1 | $self->{plural} = $self->getPlural(); | |||||||||||||||||||||||||||||||||||||||||||||
| 592 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 12 | return( $self->_set_get_array_as_object( 'plural' ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 594 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 595 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||||||
| 597 | sub pluralForms | ||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pluralForms: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | ▶ | warn( "This method pluralForms() is now deprecated." ) if( $self->_is_warnings_enabled( 'Text::PO' ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 601 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||||||
| 603 | sub po_object | ||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
po_object: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | ▶ | warn( "This method po_object() is now deprecated." ) if( $self->_is_warnings_enabled( 'Text::PO' ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 607 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||||||||||||||||
| 609 | sub poRevisionDate | ||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
poRevisionDate: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | ▶ | warn( "This method poRevisionDate() is now deprecated." ) if( $self->_is_warnings_enabled( 'Text::PO' ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 613 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||||||
| 615 | sub potCreationDate | ||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
potCreationDate: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | ▶ | warn( "This method potCreationDate() is now deprecated." ) if( $self->_is_warnings_enabled( 'Text::PO' ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 619 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||||||||||||||||||
| 621 | sub projectIdVersion | ||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
projectIdVersion: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | ▶ | warn( "This method projectIdVersion() is now deprecated." ) if( $self->_is_warnings_enabled( 'Text::PO' ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 625 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||||||
| 627 | sub reportBugsTo | ||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reportBugsTo: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 630 | 0 | ▶ | warn( "This method reportBugsTo() is now deprecated." ) if( $self->_is_warnings_enabled( 'Text::PO' ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 631 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||||||||||||||||||||
| 633 | sub textdomain | ||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
textdomain: called CC=16 SCAR=36.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 2 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 636 | 2 | ▶ | my $dom = shift( @_ ) || return( $self->error( "No domain was provided." ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift @_ || (return $self->error('No domain was provided.'))
MC/DC0%0/1
shift @_ || (return $self->error('No domain was provided.'))
shift @_
Truth table50%1/2
A
A= shift @_
| |||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 2 | ▶ | my $class = ref( $self ) || $self; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 2 | my $base = $self->path; | |||||||||||||||||||||||||||||||||||||||||||||
| 639 | 2 | my $lang = $self->locale_unix; | |||||||||||||||||||||||||||||||||||||||||||||
| 640 | 2 | ▶ | my $path_po = $base->join( $base, $lang, ( $self->category ? $self->category : () ), "${dom}.po" ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 2 | ▶ | my $path_json = $base->join( $base, $lang, ( $self->category ? $self->category : () ), "${dom}.json" ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 2 | ▶ | my $path_mo = $base->join( $base, $lang, ( $self->category ? $self->category : () ), "${dom}.mo" ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 2 | my $file; | |||||||||||||||||||||||||||||||||||||||||||||
| 644 | my $po; | ||||||||||||||||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 2 | ▶ | if( $self->use_json && $path_json->exists ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition33%1/3
$self->use_json and $path_json->exists
MC/DC0%0/2
$self->use_json and $path_json->exists
$self->use_json
$path_json->exists
Truth table33%1/3
A and B
A= $self->use_jsonB= $path_json->exists
| |||||||||||||||||||||||||||||||||||||||||||||||
| 647 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 2 | $file = $path_json; | |||||||||||||||||||||||||||||||||||||||||||||
| 649 | 2 | ▶ | $po = Text::PO->new( domain => $dom, use_json => 1, debug => $self->debug ) || | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
'Text::PO'->new('domain', $dom, 'use_json', 1, 'debug', $self->debug) || (return $self->pass_error('Text::PO'->error))
MC/DC0%0/1
'Text::PO'->new('domain', $dom, 'use_json', 1, 'debug', $self->debug) || (return $self->pass_error('Text::PO'->error))
'Text::PO'->new('domain', $dom, 'use_json', 1, 'debug', $self->debug)
Truth table50%1/2
A
A= 'Text::PO'->new('domain', $dom, 'use_json', 1, 'debug', $self->debug)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 650 | return( $self->pass_error( Text::PO->error ) ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 2 | ▶ | $po->parse2object( $file ) || | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 652 | return( $self->pass_error( $po->error ) ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 653 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 654 | elsif( $path_po->exists ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 655 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | $file = $path_po; | |||||||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | ▶ | $po = Text::PO->new( domain => $dom, debug => $self->debug ) || | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
'Text::PO'->new('domain', $dom, 'debug', $self->debug) || (return $self->pass_error('Text::PO'->error))
MC/DC0%0/1
'Text::PO'->new('domain', $dom, 'debug', $self->debug) || (return $self->pass_error('Text::PO'->error))
'Text::PO'->new('domain', $dom, 'debug', $self->debug)
Truth table0%0/2
A
A= 'Text::PO'->new('domain', $dom, 'debug', $self->debug)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 658 | return( $self->pass_error( Text::PO->error ) ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | ▶ | $po->parse( $file ) || | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 660 | return( $self->pass_error( $po->error ) ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 661 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 662 | elsif( $path_mo->exists ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 663 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 0 | $file = $path_mo; | |||||||||||||||||||||||||||||||||||||||||||||
| 665 | 0 | require Text::PO::MO; | |||||||||||||||||||||||||||||||||||||||||||||
| 666 | 0 | ▶ | my $mo = Text::PO::MO->new( $file, { domain => $dom, debug => $self->debug }) || | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
'Text::PO::MO'->new($file, {'domain', $dom, 'debug', $self->debug}) || (return $self->pass_error('Text::PO::MO'->error))
MC/DC0%0/1
'Text::PO::MO'->new($file, {'domain', $dom, 'debug', $self->debug}) || (return $self->pass_error('Text::PO::MO'->error))
'Text::PO::MO'->new($file, {'domain', $dom, 'debug', $self->debug})
Truth table0%0/2
A
A= 'Text::PO::MO'->new($file, {'domain', $dom, 'debug', $self->debug})
| |||||||||||||||||||||||||||||||||||||||||||||||
| 667 | return( $self->pass_error( Text::PO::MO->error ) ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | ▶ | $po = $mo->as_object || | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$mo->as_object || (return $self->pass_error($po->error))
MC/DC0%0/1
$mo->as_object || (return $self->pass_error($po->error))
$mo->as_object
Truth table0%0/2
A
A= $mo->as_object
| |||||||||||||||||||||||||||||||||||||||||||||||
| 669 | return( $self->pass_error( $po->error ) ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 670 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 671 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 672 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | return( $self->error( "No data file could be found for \"$dom\" for either json, po, or mo file." ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 674 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 2 | my $dict = {}; | |||||||||||||||||||||||||||||||||||||||||||||
| 676 | $po->elements->foreach(sub | ||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 18 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=7 SCAR=19.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 18 | my $e = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 679 | 18 | my $msgid = $e->msgid_as_text; | |||||||||||||||||||||||||||||||||||||||||||||
| 680 | 18 | my $msgstr = $e->msgstr; | |||||||||||||||||||||||||||||||||||||||||||||
| 681 | 18 | ▶ | return(1) if( !defined( $msgid ) || !length( $msgid // '' ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition60%3/5
defined $msgid and length($msgid // "")
$msgid // ""
MC/DC0%0/2
defined $msgid and length($msgid // "")
defined $msgid
$msgid
Truth table33%1/3
A and B
A= defined $msgidB= $msgid
| |||||||||||||||||||||||||||||||||||||||||||||||
| 682 | # We store the msgid | ||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 16 | $dict->{ $msgid } = $msgstr; | |||||||||||||||||||||||||||||||||||||||||||||
| 684 | # Also store the plural version, if any | ||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 16 | my $msgid_plural = $e->msgid_plural_as_text; | |||||||||||||||||||||||||||||||||||||||||||||
| 686 | 16 | ▶ | if( defined( $msgid_plural ) && CORE::length( $msgid_plural // '' ) ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition60%3/5
defined $msgid_plural and length($msgid_plural // "")
$msgid_plural // ""
MC/DC50%1/2
defined $msgid_plural and length($msgid_plural // "")
defined $msgid_plural
$msgid_plural
Truth table66%2/3
A and B
A= defined $msgid_pluralB= $msgid_plural
| |||||||||||||||||||||||||||||||||||||||||||||||
| 687 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 2 | $dict->{ $msgid_plural } = $msgstr; | |||||||||||||||||||||||||||||||||||||||||||||
| 689 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 2 | }); | |||||||||||||||||||||||||||||||||||||||||||||
| 691 | # Save this hash to our object. | ||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 2 | $self->{_dict} = $dict; | |||||||||||||||||||||||||||||||||||||||||||||
| 693 | 2 | $self->{_plural} = $po->plural; | |||||||||||||||||||||||||||||||||||||||||||||
| 694 | 2 | return( $self ); | |||||||||||||||||||||||||||||||||||||||||||||
| 695 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 3 | ▶ | sub use_json { return( shift->_set_get_boolean( 'use_json', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
use_json: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||||||||||||||||
| 699 | sub _get_days | ||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 4 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_days: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 4 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 702 | 4 | my $locale = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 703 | 4 | my $oldlocale = POSIX::setlocale( &POSIX::LC_ALL ); | |||||||||||||||||||||||||||||||||||||||||||||
| 704 | 4 | my $short = $self->new_array; | |||||||||||||||||||||||||||||||||||||||||||||
| 705 | 4 | my $long = $self->new_array; | |||||||||||||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 4 | ▶ | POSIX::setlocale( &POSIX::LC_ALL, $locale ) if( defined( $locale ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 4 | ▶ | for (my $i = 1; $i <= 7; $i++) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 710 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 711 | # my $const = "I18N::Langinfo::ABDAY_${i}"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 28 | my $const = I18N::Langinfo->can( "ABDAY_${i}" ); | |||||||||||||||||||||||||||||||||||||||||||||
| 713 | # $short->[$i-1] = langinfo( &$const ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 28 | $short->[$i-1] = langinfo( $const->() ); | |||||||||||||||||||||||||||||||||||||||||||||
| 715 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 4 | ▶ | for (my $i = 1; $i <= 7; $i++) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 717 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 718 | # my $const = "I18N::Langinfo::DAY_${i}"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 28 | my $const = I18N::Langinfo->can( "DAY_${i}" ); | |||||||||||||||||||||||||||||||||||||||||||||
| 720 | # $long->[$i-1] = langinfo( &$const ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 28 | $long->[$i-1] = langinfo( $const->() ); | |||||||||||||||||||||||||||||||||||||||||||||
| 722 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 4 | ▶ | POSIX::setlocale( &POSIX::LC_ALL, $oldlocale) if( defined( $locale ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 4 | return( [ $short, $long ] ); | |||||||||||||||||||||||||||||||||||||||||||||
| 727 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||||||||||||||||||||
| 729 | sub _get_months | ||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_months: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 2 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 732 | 2 | my $locale = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 733 | 2 | my $oldlocale = POSIX::setlocale( &POSIX::LC_ALL ); | |||||||||||||||||||||||||||||||||||||||||||||
| 734 | 2 | my $short = $self->new_array; | |||||||||||||||||||||||||||||||||||||||||||||
| 735 | 2 | my $long = $self->new_array; | |||||||||||||||||||||||||||||||||||||||||||||
| 736 | |||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 2 | ▶ | POSIX::setlocale( &POSIX::LC_ALL, $locale ) if( defined( $locale ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 2 | ▶ | for( my $i = 1; $i <= 12; $i++ ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 740 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 741 | # my $const = "I18N::Langinfo::ABMON_${i}"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 742 | # $short->[$i-1] = langinfo( &$const ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 24 | my $const = I18N::Langinfo->can( "ABMON_${i}" ); | |||||||||||||||||||||||||||||||||||||||||||||
| 744 | 24 | $short->[$i-1] = langinfo( $const->() ); | |||||||||||||||||||||||||||||||||||||||||||||
| 745 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 2 | ▶ | for( my $i = 1; $i <= 12; $i++ ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 747 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 748 | # my $const = "I18N::Langinfo::MON_${i}"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 749 | # $long->[$i-1] = langinfo( &$const ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 24 | my $const = I18N::Langinfo->can( "MON_${i}" ); | |||||||||||||||||||||||||||||||||||||||||||||
| 751 | 24 | $long->[$i-1] = langinfo( $const->() ); | |||||||||||||||||||||||||||||||||||||||||||||
| 752 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 2 | ▶ | POSIX::setlocale( &POSIX::LC_ALL, $oldlocale) if( defined( $locale ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 755 | |||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 2 | return( [ $short, $long ] ); | |||||||||||||||||||||||||||||||||||||||||||||
| 757 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||||||||||||||||||||
| 759 | sub _get_numeric_dict | ||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_numeric_dict: called CC=13 SCAR=31.1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 2 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 762 | 2 | my $locale = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 763 | 2 | my $oldlocale = POSIX::setlocale( &POSIX::LC_ALL ); | |||||||||||||||||||||||||||||||||||||||||||||
| 764 | 2 | ▶ | POSIX::setlocale( &POSIX::LC_ALL, $locale) if( defined( $locale ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 2 | my $lconv = POSIX::localeconv(); | |||||||||||||||||||||||||||||||||||||||||||||
| 766 | 2 | ▶ | POSIX::setlocale( &POSIX::LC_ALL, $oldlocale) if( defined( $locale ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 2 | my $def = $self->new_hash; | |||||||||||||||||||||||||||||||||||||||||||||
| 768 | @$def{qw( currency decimal int_currency negative_sign thousand precision )} = | ||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 2 | @$lconv{qw( currency_symbol decimal_point int_curr_symbol negative_sign thousands_sep frac_digits )}; | |||||||||||||||||||||||||||||||||||||||||||||
| 770 | 2 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 2 | ▶ | $def->{currency} = '€' if( CORE::exists( $def->{currency} ) && defined( $def->{currency} ) && $def->{currency} eq 'EUR' ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
exists $def->{"currency"} and defined $def->{"currency"} and $def->{"currency"} eq "EUR"
exists $def->{"currency"} and defined $def->{"currency"}
MC/DC0%0/3
exists $def->{"currency"} and defined $def->{"currency"} and $def->{"currency"} eq "EUR"
exists $def->{"currency"}
defined $def->{"currency"}
$def->{"currency"} eq "EUR"
Truth table25%1/4
A and B and C
A= exists $def->{"currency"}B= defined $def->{"currency"}C= $def->{"currency"} eq "EUR"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 2 | ▶ | $lconv->{currency_symbol} = '€' if( CORE::exists( $lconv->{currency_symbol} ) && defined( $lconv->{currency_symbol} ) && $lconv->{currency_symbol} eq 'EUR' ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
exists $lconv->{"currency_symbol"} and defined $lconv->{"currency_symbol"} and $lconv->{"currency_symbol"} eq "EUR"
exists $lconv->{"currency_symbol"} and defined $lconv->{"currency_symbol"}
MC/DC0%0/3
exists $lconv->{"currency_symbol"} and defined $lconv->{"currency_symbol"} and $lconv->{"currency_symbol"} eq "EUR"
exists $lconv->{"currency_symbol"}
defined $lconv->{"currency_symbol"}
$lconv->{"currency_symbol"} eq "EUR"
Truth table25%1/4
A and B and C
A= exists $lconv->{"currency_symbol"}B= defined $lconv->{"currency_symbol"}C= $lconv->{"currency_symbol"} eq "EUR"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 2 | ▶ | $lconv->{grouping} = unpack( "C*", $lconv->{grouping} ) if( CORE::exists( $lconv->{grouping} ) && defined( $lconv->{grouping} ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $lconv->{"grouping"} and defined $lconv->{"grouping"}
MC/DC0%0/2
exists $lconv->{"grouping"} and defined $lconv->{"grouping"}
exists $lconv->{"grouping"}
defined $lconv->{"grouping"}
Truth table33%1/3
A and B
A= exists $lconv->{"grouping"}B= defined $lconv->{"grouping"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 2 | ▶ | $lconv->{mon_grouping} = unpack( "C*", $lconv->{mon_grouping} ) if( CORE::exists( $lconv->{mon_grouping} ) && defined( $lconv->{mon_grouping} ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $lconv->{"mon_grouping"} and defined $lconv->{"mon_grouping"}
MC/DC0%0/2
exists $lconv->{"mon_grouping"} and defined $lconv->{"mon_grouping"}
exists $lconv->{"mon_grouping"}
defined $lconv->{"mon_grouping"}
Truth table33%1/3
A and B
A= exists $lconv->{"mon_grouping"}B= defined $lconv->{"mon_grouping"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 2 | $lconv = $self->new_hash( $lconv ); | |||||||||||||||||||||||||||||||||||||||||||||
| 776 | 2 | return( [ $def, $lconv ] ); | |||||||||||||||||||||||||||||||||||||||||||||
| 777 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||||||||||||||||||||
| 779 | # NOTE: Text::PO::String class | ||||||||||||||||||||||||||||||||||||||||||||||
| 780 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 781 | package | ||||||||||||||||||||||||||||||||||||||||||||||
| 782 | Text::PO::String; | ||||||||||||||||||||||||||||||||||||||||||||||
| 783 | BEGIN | ||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 785 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 2 | ▶ | use parent qw( Module::Generic ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 2 | ▶ | use vars qw( $VERSION ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 2 | our $VERSION = 'v0.1.0'; | |||||||||||||||||||||||||||||||||||||||||||||
| 790 | 2 | ▶ | use overload ( | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||||||||||||||||||
| 791 | '""' => 'as_string', | ||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 0 | ▶ | 'bool' => sub{1}, | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 2 | fallback => 1, | |||||||||||||||||||||||||||||||||||||||||||||
| 794 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||
| 795 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 799 | |||||||||||||||||||||||||||||||||||||||||||||||
| 800 | sub init | ||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 12 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 12 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 803 | 12 | my $value = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 804 | 12 | my $locale = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 805 | 12 | $self->{locale} = $locale; | |||||||||||||||||||||||||||||||||||||||||||||
| 806 | 12 | $self->{value} = $value; | |||||||||||||||||||||||||||||||||||||||||||||
| 807 | 12 | $self->SUPER::init( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 808 | 12 | return( $self ); | |||||||||||||||||||||||||||||||||||||||||||||
| 809 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 810 | |||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 12 | ▶ | sub as_string { return( shift->value->scalar ); } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_string: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 812 | |||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 1 | ▶ | sub locale { return( shift->_set_get_scalar_as_object( 'locale', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
locale: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 12 | ▶ | sub value { return( shift->_set_get_scalar_as_object( 'value', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
value: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 816 | |||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 0 | ▶ | sub TO_JSON { return( shift->as_string ); } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TO_JSON: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 818 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 819 | |||||||||||||||||||||||||||||||||||||||||||||||
| 820 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 821 | # NOTE: POD | ||||||||||||||||||||||||||||||||||||||||||||||
| 822 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||