Completed
Push — master ( 6a08aa...2252e8 )
by William
03:47
created

functions.php ➔ _npgettext()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 4
dl 0
loc 9
ccs 0
cts 0
cp 0
crap 2
rs 9.9666
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
    Copyright (c) 2005 Steven Armstrong <sa at c-area dot ch>
7
    Copyright (c) 2009 Danilo Segan <[email protected]>
8
    Copyright (c) 2016 Michal Čihař <[email protected]>
9
10
    This file is part of MoTranslator.
11
12
    This program is free software; you can redistribute it and/or modify
13
    it under the terms of the GNU General Public License as published by
14
    the Free Software Foundation; either version 2 of the License, or
15
    (at your option) any later version.
16
17
    This program is distributed in the hope that it will be useful,
18
    but WITHOUT ANY WARRANTY; without even the implied warranty of
19
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
    GNU General Public License for more details.
21
22
    You should have received a copy of the GNU General Public License along
23
    with this program; if not, write to the Free Software Foundation, Inc.,
24
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25
*/
26
27
use PhpMyAdmin\MoTranslator\Loader;
28
29
/**
30
 * Sets a requested locale.
31
 *
32
 * @param int    $category Locale category, ignored
33
 * @param string $locale   Locale name
34
 *
35
 * @return string Set or current locale
36
 */
37
function _setlocale(int $category, string $locale): string
0 ignored issues
show
Unused Code introduced by
The parameter $category is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

37
function _setlocale(/** @scrutinizer ignore-unused */ int $category, string $locale): string

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
38
{
39 8
    return Loader::getInstance()->setlocale($locale);
40
}
41
42
/**
43
 * Sets the path for a domain.
44
 *
45
 * @param string $domain Domain name
46
 * @param string $path   Path where to find locales
47
 */
48
function _bindtextdomain(string $domain, string $path): void
49
{
50 8
    Loader::getInstance()->bindtextdomain($domain, $path);
51 8
}
52
53
/**
54
 * Dummy compatibility function, MoTranslator assumes
55
 * everything is using same character set on input and
56
 * output.
57
 *
58
 * Generally it is wise to output in UTF-8 and have
59
 * mo files in UTF-8.
60
 *
61
 * @param mixed $domain  Domain where to set character set
62
 * @param mixed $codeset Character set to set
63
 */
64
function _bind_textdomain_codeset($domain, $codeset): void
0 ignored issues
show
Unused Code introduced by
The parameter $domain is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

64
function _bind_textdomain_codeset(/** @scrutinizer ignore-unused */ $domain, $codeset): void

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $codeset is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

64
function _bind_textdomain_codeset($domain, /** @scrutinizer ignore-unused */ $codeset): void

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
65
{
66 8
}
67
68
/**
69
 * Sets the default domain.
70
 *
71
 * @param string $domain Domain name
72
 */
73
function _textdomain(string $domain): void
74
{
75 8
    Loader::getInstance()->textdomain($domain);
76 8
}
77
78
/**
79
 * Translates a string.
80
 *
81
 * @param string $msgid String to be translated
82
 *
83
 * @return string translated string (or original, if not found)
84
 */
85
function _gettext(string $msgid): string
86
{
87 4
    return Loader::getInstance()->getTranslator()->gettext(
88 4
        $msgid
89
    );
90
}
91
92
/**
93
 * Translates a string, alias for _gettext.
94
 *
95
 * @param string $msgid String to be translated
96
 *
97
 * @return string translated string (or original, if not found)
98
 */
99
function __(string $msgid): string
100
{
101 4
    return Loader::getInstance()->getTranslator()->gettext(
102 4
        $msgid
103
    );
104
}
105
106
/**
107
 * Plural version of gettext.
108
 *
109
 * @param string $msgid       Single form
110
 * @param string $msgidPlural Plural form
111
 * @param int    $number      Number of objects
112
 *
113
 * @return string translated plural form
114
 */
115
function _ngettext(string $msgid, string $msgidPlural, int $number): string
116
{
117 4
    return Loader::getInstance()->getTranslator()->ngettext(
118 4
        $msgid,
119 2
        $msgidPlural,
120 2
        $number
121
    );
122
}
123
124
/**
125
 * Translate with context.
126
 *
127
 * @param string $msgctxt Context
128
 * @param string $msgid   String to be translated
129
 *
130
 * @return string translated plural form
131
 */
132
function _pgettext(string $msgctxt, string $msgid): string
133
{
134 4
    return Loader::getInstance()->getTranslator()->pgettext(
135 4
        $msgctxt,
136 2
        $msgid
137
    );
138
}
139
140
/**
141
 * Plural version of pgettext.
142
 *
143
 * @param string $msgctxt     Context
144
 * @param string $msgid       Single form
145
 * @param string $msgidPlural Plural form
146
 * @param int    $number      Number of objects
147
 *
148
 * @return string translated plural form
149
 */
150
function _npgettext(string $msgctxt, string $msgid, string $msgidPlural, int $number): string
151
{
152 4
    return Loader::getInstance()->getTranslator()->npgettext(
153 4
        $msgctxt,
154 2
        $msgid,
155 2
        $msgidPlural,
156 2
        $number
157
    );
158
}
159
160
/**
161
 * Translates a string.
162
 *
163
 * @param string $domain Domain to use
164
 * @param string $msgid  String to be translated
165
 *
166
 * @return string translated string (or original, if not found)
167
 */
168
function _dgettext(string $domain, string $msgid): string
169
{
170 4
    return Loader::getInstance()->getTranslator($domain)->gettext(
171 4
        $msgid
172
    );
173
}
174
175
/**
176
 * Plural version of gettext.
177
 *
178
 * @param string $domain      Domain to use
179
 * @param string $msgid       Single form
180
 * @param string $msgidPlural Plural form
181
 * @param int    $number      Number of objects
182
 *
183
 * @return string translated plural form
184
 */
185
function _dngettext(string $domain, string $msgid, string $msgidPlural, int $number): string
186
{
187 4
    return Loader::getInstance()->getTranslator($domain)->ngettext(
188 4
        $msgid,
189 2
        $msgidPlural,
190 2
        $number
191
    );
192
}
193
194
/**
195
 * Translate with context.
196
 *
197
 * @param string $domain  Domain to use
198
 * @param string $msgctxt Context
199
 * @param string $msgid   String to be translated
200
 *
201
 * @return string translated plural form
202
 */
203
function _dpgettext(string $domain, string $msgctxt, string $msgid): string
204
{
205 4
    return Loader::getInstance()->getTranslator($domain)->pgettext(
206 4
        $msgctxt,
207 2
        $msgid
208
    );
209
}
210
211
/**
212
 * Plural version of pgettext.
213
 *
214
 * @param string $domain      Domain to use
215
 * @param string $msgctxt     Context
216
 * @param string $msgid       Single form
217
 * @param string $msgidPlural Plural form
218
 * @param int    $number      Number of objects
219
 *
220
 * @return string translated plural form
221
 */
222
function _dnpgettext(string $domain, string $msgctxt, string $msgid, string $msgidPlural, int $number): string
223
{
224 4
    return Loader::getInstance()->getTranslator($domain)->npgettext(
225 4
        $msgctxt,
226 2
        $msgid,
227 2
        $msgidPlural,
228 2
        $number
229
    );
230
}
231