gettext_dumb.pm

filter: Statementstmt 64.2% 36 / 56 Branchbran 100% 8 / 8 Conditioncond 66.6% 8 / 12 MC/DCmcdc 50.0% 4 / 8 Subroutinesub 37.5% 6 / 16 Podpod 0.0% 0 / 13 totaltotal 54.8% 62 / 113 CC 9 SCAR 15.0
CC
9
Cov
68%
__get_locale
9.2
dgettext
2.0
dcgettext
2.0
CRAP 4.5
« Recode.pm ↑ Summary Messages.pm »
1 #! /bin/false
2  
3 # vim: set autoindent shiftwidth=4 tabstop=4:
4  
5 # Pure Perl implementation of Uniforum message translation.
6 # Copyright (C) 2002-2026 Guido Flohr <guido.flohr@cantanea.com>,
7 # all rights reserved.
8  
9 # This program is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 3 of the License, or
12 # (at your option) any later version.
13  
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
18  
19 # You should have received a copy of the GNU General Public License
20 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21  
22 package Locale::gettext_dumb;
23  
24 1 ▶use Locale::gettext_pp;
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 1 ▶use vars qw (%EXPORT_TAGS @EXPORT_OK @ISA $VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 1 %EXPORT_TAGS = (locale_h => [ qw (gettext
29 dgettext
30 dcgettext
31 ngettext
32 dngettext
33 dcngettext
34 pgettext
35 dpgettext
36 dcpgettext
37 npgettext
38 dnpgettext
39 dcnpgettext
40 textdomain
41 bindtextdomain
42 bind_textdomain_codeset
43 )],
44 libintl_h => [ qw (LC_CTYPE
45 LC_NUMERIC
46 LC_TIME
47 LC_COLLATE
48 LC_MONETARY
49 LC_MESSAGES
50 LC_ALL)],
51 );
52  
53 1 @EXPORT_OK = qw (gettext
54 dgettext
55 dcgettext
56 ngettext
57 dngettext
58 dcngettext
59 pgettext
60 dpgettext
61 dcpgettext
62 npgettext
63 dnpgettext
64 dcnpgettext
65 textdomain
66 bindtextdomain
67 bind_textdomain_codeset
68 nl_putenv
69 setlocale
70 LC_CTYPE
71 LC_NUMERIC
72 LC_TIME
73 LC_COLLATE
74 LC_MONETARY
75 LC_MESSAGES
76 LC_ALL);
77
78 1 @ISA = qw (Exporter);
79  
80 1 *Locale::gettext_dumb::textdomain = \&Locale::gettext_pp::textdomain;
81 1 *Locale::gettext_dumb::bindtextdomain = \&Locale::gettext_pp::bindtextdomain;
82 1 *Locale::gettext_dumb::bind_textdomain_codeset =
83 \&Locale::gettext_pp::bind_textdomain_codeset;
84  
85 1 *Locale::gettext_dumb::nl_putenv = \&Locale::gettext_pp::nl_putenv;
86  
87 1 *Locale::gettext_dumb::LC_CTYPE = \&Locale::gettext_pp::LC_CTYPE;
88 1 *Locale::gettext_dumb::LC_NUMERIC = \&Locale::gettext_pp::LC_NUMERIC;
89 1 *Locale::gettext_dumb::LC_TIME= \&Locale::gettext_pp::LC_TIME;
90 1 *Locale::gettext_dumb::LC_COLLATE = \&Locale::gettext_pp::LC_COLLATE;
91 1 *Locale::gettext_dumb::LC_MONETARY = \&Locale::gettext_pp::LC_MONETARY;
92 1 *Locale::gettext_dumb::LC_MESSAGES = \&Locale::gettext_pp::LC_MESSAGES;
93 1 *Locale::gettext_dumb::LC_ALL = \&Locale::gettext_pp::LC_ALL;
94  
95  
96 9 ▶sub gettext ($) {
Subroutine gettext: called CC=1 SCAR=0.0
Pod undocumented
97 9 my ($msgid) = @_;
98  
99 9 return dcnpgettext ('', undef, $msgid, undef, undef, undef);
100 }
101  
102 0 ▶sub dgettext ($$) {
Subroutine dgettext: not called CC=1 SCAR=6.9
Pod undocumented
103 0 my ($domainname, $msgid) = @_;
104  
105 0 return dcnpgettext ($domainname, undef, $msgid, undef, undef, undef);
106 }
107  
108 0 ▶sub dcgettext ($$$) {
Subroutine dcgettext: not called CC=1 SCAR=6.9
Pod undocumented
109 0 my ($domainname, $msgid, $category) = @_;
110  
111 0 return dcnpgettext ($domainname, undef, $msgid, undef, undef, undef);
112 }
113  
114 0 ▶sub ngettext ($$$) {
Subroutine ngettext: not called CC=1 SCAR=6.9
Pod undocumented
115 0 my ($msgid, $msgid_plural, $n) = @_;
116  
117 0 return dcnpgettext ('', undef, $msgid, $msgid_plural, $n, undef);
118 }
119  
120 0 ▶sub dngettext ($$$$) {
Subroutine dngettext: not called CC=1 SCAR=6.9
Pod undocumented
121 0 my ($domainname, $msgid, $msgid_plural, $n) = @_;
122  
123 0 return dcnpgettext ($domainname, undef, $msgid, $msgid_plural, $n, undef);
124 }
125  
126 0 ▶sub dcngettext ($$$$$) {
Subroutine dcngettext: not called CC=1 SCAR=6.9
Pod undocumented
127 0 my ($domainname, $msgid, $msgid_plural, $n, $category) = @_;
128  
129 0 return dcnpgettext ($domainname, undef, $msgid, $msgid_plural, $n, ,
130 $category);
131 }
132  
133 0 ▶sub pgettext ($$) {
Subroutine pgettext: not called CC=1 SCAR=6.9
Pod undocumented
134 0 my ($msgctxt, $msgid) = @_;
135  
136 0 return dcnpgettext ('', $msgctxt, $msgid, undef, undef, undef);
137 }
138  
139 0 ▶sub dpgettext ($$$) {
Subroutine dpgettext: not called CC=1 SCAR=6.9
Pod undocumented
140 0 my ($domainname, $msgctxt, $msgid) = @_;
141  
142 0 return dcnpgettext ($domainname, $msgctxt, $msgid, undef, undef, undef);
143 }
144  
145 0 ▶sub dcpgettext($$$$) {
Subroutine dcpgettext: not called CC=1 SCAR=6.9
Pod undocumented
146 0 my ($domainname, $msgctxt, $msgid, $category) = @_;
147  
148 0 return dcnpgettext ($domainname, $msgctxt, $msgid, undef, undef, undef);
149 }
150  
151 0 ▶sub npgettext ($$$$) {
Subroutine npgettext: not called CC=1 SCAR=6.9
Pod undocumented
152 0 my ($msgctxt, $msgid, $msgid_plural, $n) = @_;
153  
154 0 return dcnpgettext ('', $msgctxt, $msgid, $msgid_plural, $n, undef);
155 }
156  
157 0 ▶sub dnpgettext ($$$$$) {
Subroutine dnpgettext: not called CC=1 SCAR=6.9
Pod undocumented
158 0 my ($domainname, $msgctxt, $msgid, $msgid_plural, $n) = @_;
159  
160 0 return dcnpgettext ($domainname, $msgctxt, $msgid, $msgid_plural, $n, undef);
161 }
162  
163 9 ▶sub __get_locale() {
Subroutine __get_locale: called CC=9 SCAR=22.2
164 9 my $locale;
165  
166 9 ▶ if (exists $ENV{LANGUAGE} && length $ENV{LANGUAGE}) {
Branch: 4 branches
BranchTrueFalseTotal
if (exists $ENV{'LANGUAGE'} and length $ENV{'LANGUAGE'}) { } 2 7 9
elsif (exists $ENV{'LC_ALL'} and length $ENV{'LC_ALL'}) { } 2 5 7
elsif (exists $ENV{'LANG'} and length $ENV{'LANG'}) { } 2 3 5
elsif (exists $ENV{'LC_MESSAGES'} and length $ENV{'LC_MESSAGES'}) { } 2 1 3
Condition66%2/3
exists $ENV{"LANGUAGE"} and length $ENV{"LANGUAGE"}
!ll&&!rl&&r
702
MC/DC50%1/2
exists $ENV{"LANGUAGE"} and length $ENV{"LANGUAGE"}
exists $ENV{"LANGUAGE"} length $ENV{"LANGUAGE"}
Truth table66%2/3
A and B
A= exists $ENV{"LANGUAGE"}B= length $ENV{"LANGUAGE"}
ABresult
0X0
100
111
167 2 $locale = $ENV{LANGUAGE};
168 2 $locale =~ s/:.*//s;
169 ▶ } elsif (exists $ENV{LC_ALL} && length $ENV{LC_ALL}) {
Condition66%2/3
exists $ENV{"LC_ALL"} and length $ENV{"LC_ALL"}
!ll&&!rl&&r
502
MC/DC50%1/2
exists $ENV{"LC_ALL"} and length $ENV{"LC_ALL"}
exists $ENV{"LC_ALL"} length $ENV{"LC_ALL"}
Truth table66%2/3
A and B
A= exists $ENV{"LC_ALL"}B= length $ENV{"LC_ALL"}
ABresult
0X0
100
111
170 2 $locale = $ENV{LC_ALL};
171 ▶ } elsif (exists $ENV{LANG} && length $ENV{LANG}) {
Condition66%2/3
exists $ENV{"LANG"} and length $ENV{"LANG"}
!ll&&!rl&&r
302
MC/DC50%1/2
exists $ENV{"LANG"} and length $ENV{"LANG"}
exists $ENV{"LANG"} length $ENV{"LANG"}
Truth table66%2/3
A and B
A= exists $ENV{"LANG"}B= length $ENV{"LANG"}
ABresult
0X0
100
111
172 2 $locale = $ENV{LANG};
173 ▶ } elsif (exists $ENV{LC_MESSAGES} && length $ENV{LC_MESSAGES}) {
Condition66%2/3
exists $ENV{"LC_MESSAGES"} and length $ENV{"LC_MESSAGES"}
!ll&&!rl&&r
102
MC/DC50%1/2
exists $ENV{"LC_MESSAGES"} and length $ENV{"LC_MESSAGES"}
exists $ENV{"LC_MESSAGES"} length $ENV{"LC_MESSAGES"}
Truth table66%2/3
A and B
A= exists $ENV{"LC_MESSAGES"}B= length $ENV{"LC_MESSAGES"}
ABresult
0X0
100
111
174 2 $locale = $ENV{LC_MESSAGES};
175 } else {
176 1 $locale = 'C';
177 }
178
179 9 return $locale;
180 }
181  
182 9 ▶sub dcnpgettext ($$$$$$) {
Subroutine dcnpgettext: called CC=1 SCAR=0.0
Pod undocumented
183 9 my ($domainname, $msgctxt, $msgid, $msgid_plural, $n, $category) = @_;
184  
185 9 my $locale = __get_locale;
186  
187 9 return Locale::gettext_pp::_dcnpgettext_impl ($domainname, $msgctxt,
188 $msgid, $msgid_plural, $n,
189 $category, $locale);
190 }
191  
192 1 ▶sub setlocale($;$) {
Subroutine setlocale: called CC=1 SCAR=0.0
Pod undocumented
193 1 &POSIX::setlocale;
194 }
195  
196 1 1;
197  
198 __END__
« Recode.pm ↑ Summary Messages.pm »