Completed
Push — master ( ebec50...7237ab )
by Michal
04:29
created

functions.php ➔ _dnpgettext()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1.125

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 5
dl 0
loc 6
ccs 1
cts 2
cp 0.5
crap 1.125
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/*
3
    Copyright (c) 2005 Steven Armstrong <sa at c-area dot ch>
4
    Copyright (c) 2009 Danilo Segan <[email protected]>
5
    Copyright (c) 2016 Michal Čihař <[email protected]>
6
7
    This file is part of MoTranslator.
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 2 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 along
20
    with this program; if not, write to the Free Software Foundation, Inc.,
21
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22
*/
23
24
use PhpMyAdmin\MoTranslator\Loader;
25
26
/**
27
 * Sets a requested locale.
28
 *
29
 * @param int    $category Locale category, ignored
30
 * @param string $locale   Locale name
31
 *
32
 * @return string Set or current locale
33
 */
34
function _setlocale($category, $locale)
35
{
36 2
    return Loader::getInstance()->setlocale($locale);
37
}
38
39
/**
40
 * Sets the path for a domain.
41
 *
42
 * @param string $domain Domain name
43
 * @param string $path   Path where to find locales
44
 */
45
function _bindtextdomain($domain, $path)
46
{
47 2
    Loader::getInstance()->bindtextdomain($domain, $path);
48 2
}
49
50
/**
51
 * Dummy compatibility function, MoTranslator assumes
52
 * everything is using same character set on input and
53
 * output.
54
 *
55
 * Generally it is wise to output in UTF-8 and have
56
 * mo files in UTF-8.
57
 *
58
 * @param mixed $domain  Domain where to set character set
59
 * @param mixed $codeset Character set to set
60
 */
61
function _bind_textdomain_codeset($domain, $codeset)
62
{
63 2
}
64
65
/**
66
 * Sets the default domain.
67
 *
68
 * @param string $domain Domain name
69
 */
70
function _textdomain($domain)
71
{
72 2
    Loader::getInstance()->textdomain($domain);
73 2
}
74
75
/**
76
 * Translates a string.
77
 *
78
 * @param string $msgid String to be translated
79
 *
80
 * @return string translated string (or original, if not found)
81
 */
82
function _gettext($msgid)
83
{
84 1
    return Loader::getInstance()->getTranslator()->gettext(
85
        $msgid
86
    );
87
}
88
89
/**
90
 * Translates a string, alias for _gettext.
91
 *
92
 * @param string $msgid String to be translated
93
 *
94
 * @return string translated string (or original, if not found)
95
 */
96
function __($msgid)
97
{
98 1
    return Loader::getInstance()->getTranslator()->gettext(
99
        $msgid
100
    );
101
}
102
103
/**
104
 * Plural version of gettext.
105
 *
106
 * @param string $msgid       Single form
107
 * @param string $msgidPlural Plural form
108
 * @param int    $number      Number of objects
109
 *
110
 * @return string translated plural form
111
 */
112
function _ngettext($msgid, $msgidPlural, $number)
113
{
114 1
    return Loader::getInstance()->getTranslator()->ngettext(
115
        $msgid, $msgidPlural, $number
116
    );
117
}
118
119
/**
120
 * Translate with context.
121
 *
122
 * @param string $msgctxt Context
123
 * @param string $msgid   String to be translated
124
 *
125
 * @return string translated plural form
126
 */
127
function _pgettext($msgctxt, $msgid)
128
{
129 1
    return Loader::getInstance()->getTranslator()->pgettext(
130
        $msgctxt, $msgid
131
    );
132
}
133
134
/**
135
 * Plural version of pgettext.
136
 *
137
 * @param string $msgctxt     Context
138
 * @param string $msgid       Single form
139
 * @param string $msgidPlural Plural form
140
 * @param int    $number      Number of objects
141
 *
142
 * @return string translated plural form
143
 */
144
function _npgettext($msgctxt, $msgid, $msgidPlural, $number)
145
{
146 1
    return Loader::getInstance()->getTranslator()->npgettext(
147
        $msgctxt, $msgid, $msgidPlural, $number
148
    );
149
}
150
151
/**
152
 * Translates a string.
153
 *
154
 * @param string $domain Domain to use
155
 * @param string $msgid  String to be translated
156
 *
157
 * @return string translated string (or original, if not found)
158
 */
159
function _dgettext($domain, $msgid)
160
{
161 1
    return Loader::getInstance()->getTranslator($domain)->gettext(
162
        $msgid
163
    );
164
}
165
166
/**
167
 * Plural version of gettext.
168
 *
169
 * @param string $domain      Domain to use
170
 * @param string $msgid       Single form
171
 * @param string $msgidPlural Plural form
172
 * @param int    $number      Number of objects
173
 *
174
 * @return string translated plural form
175
 */
176
function _dngettext($domain, $msgid, $msgidPlural, $number)
177
{
178 1
    return Loader::getInstance()->getTranslator($domain)->ngettext(
179
        $msgid, $msgidPlural, $number
180
    );
181
}
182
183
/**
184
 * Translate with context.
185
 *
186
 * @param string $domain  Domain to use
187
 * @param string $msgctxt Context
188
 * @param string $msgid   String to be translated
189
 *
190
 * @return string translated plural form
191
 */
192
function _dpgettext($domain, $msgctxt, $msgid)
193
{
194 1
    return Loader::getInstance()->getTranslator($domain)->pgettext(
195
        $msgctxt, $msgid
196
    );
197
}
198
199
/**
200
 * Plural version of pgettext.
201
 *
202
 * @param string $domain      Domain to use
203
 * @param string $msgctxt     Context
204
 * @param string $msgid       Single form
205
 * @param string $msgidPlural Plural form
206
 * @param int    $number      Number of objects
207
 *
208
 * @return string translated plural form
209
 */
210
function _dnpgettext($domain, $msgctxt, $msgid, $msgidPlural, $number)
211
{
212 1
    return Loader::getInstance()->getTranslator($domain)->npgettext(
213
        $msgctxt, $msgid, $msgidPlural, $number
214
    );
215
}
216