Completed
Push — master ( c470ca...524814 )
by Michal
04:03
created

functions.php ➔ _bindtextdomain()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
c 1
b 0
f 1
nc 1
nop 2
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
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 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
 * @return void
46
 */
47
function _bindtextdomain($domain, $path)
48
{
49 2
    Loader::getInstance()->bindtextdomain($domain, $path);
50 2
}
51
52
/**
53
 * Dummy compatibility function, MoTranslator assumes
54
 * everything is UTF-8
55
 *
56
 * @return void
57
 */
58
function _bind_textdomain_codeset($domain, $codeset) {
59 2
    return;
60
}
61
62
/**
63
 * Sets the default domain.
64
 *
65
 * @param string $domain Domain name
66
 *
67
 * @return void
68
 */
69
function _textdomain($domain)
70
{
71 2
    Loader::getInstance()->textdomain($domain);
72 2
}
73
74
/**
75
 * Translates a string
76
 *
77
 * @param string $msgid String to be translated
78
 *
79
 * @return string translated string (or original, if not found)
80
 */
81
function _gettext($msgid)
82
{
83 1
    return Loader::getInstance()->get_translator()->gettext(
84
        $msgid
85 1
    );
86
}
87
88
/**
89
 * Translates a string, alias for _gettext
90
 *
91
 * @param string $msgid String to be translated
92
 *
93
 * @return string translated string (or original, if not found)
94
 */
95
function __($msgid)
96
{
97 1
    return Loader::getInstance()->get_translator()->gettext(
98
        $msgid
99 1
    );
100
}
101
102
/**
103
 * Plural version of gettext
104
 *
105
 * @param string $msgid        Single form
106
 * @param string $msgid_plural Plural form
107
 * @param string $number       Number of objects
108
 *
109
 * @return string translated plural form
110
 */
111
function _ngettext($msgid, $msgid_plural, $number)
112
{
113 1
    return Loader::getInstance()->get_translator()->ngettext(
114 1
        $msgid, $msgid_plural, $number
115 1
    );
116
}
117
118
/**
119
 * Translate with context
120
 *
121
 * @param string $msgctxt      Context
122
 * @param string $msgid        String to be translated
123
 *
124
 * @return string translated plural form
125
 */
126
function _pgettext($msgctxt, $msgid)
127
{
128 1
    return Loader::getInstance()->get_translator()->pgettext(
129 1
        $msgctxt, $msgid
130 1
    );
131
}
132
133
/**
134
 * Plural version of pgettext
135
 *
136
 * @param string $msgctxt      Context
137
 * @param string $msgid        Single form
138
 * @param string $msgid_plural Plural form
139
 * @param string $number       Number of objects
140
 *
141
 * @return string translated plural form
142
 */
143
function _npgettext($msgctxt, $msgid, $msgid_plural, $number)
144
{
145 1
    return Loader::getInstance()->get_translator()->npgettext(
146 1
        $msgctxt, $msgid, $msgid_plural, $number
147 1
    );
148
}
149
150
/**
151
 * Translates a string
152
 *
153
 * @param string $domain Domain to use
154
 * @param string $msgid  String to be translated
155
 *
156
 * @return string translated string (or original, if not found)
157
 */
158
function _dgettext($domain, $msgid)
159
{
160 1
    return Loader::getInstance()->get_translator($domain)->gettext(
161
        $msgid
162 1
    );
163
}
164
165
/**
166
 * Plural version of gettext
167
 *
168
 * @param string $domain       Domain to use
169
 * @param string $msgid        Single form
170
 * @param string $msgid_plural Plural form
171
 * @param string $number       Number of objects
172
 *
173
 * @return string translated plural form
174
 */
175
function _dngettext($domain, $msgid, $msgid_plural, $number)
176 1
{
177 1
    return Loader::getInstance()->get_translator($domain)->ngettext(
178 1
        $msgid, $msgid_plural, $number
179 1
    );
180
}
181
182
/**
183
 * Translate with context
184
 *
185
 * @param string $domain  Domain to use
186
 * @param string $msgctxt Context
187
 * @param string $msgid   String to be translated
188
 *
189
 * @return string translated plural form
190
 */
191
function _dpgettext($domain, $msgctxt, $msgid)
192
{
193 1
    return Loader::getInstance()->get_translator($domain)->pgettext(
194 1
        $msgctxt, $msgid
195 1
    );
196
}
197
198
/**
199
 * Plural version of pgettext
200
 *
201
 * @param string $domain       Domain to use
202
 * @param string $msgctxt      Context
203
 * @param string $msgid        Single form
204
 * @param string $msgid_plural Plural form
205
 * @param string $number       Number of objects
206
 *
207
 * @return string translated plural form
208
 */
209
function _dnpgettext($domain, $msgctxt, $msgid, $msgid_plural, $number)
210
{
211 1
    return Loader::getInstance()->get_translator($domain)->npgettext(
212 1
        $msgctxt, $msgid, $msgid_plural, $number
213 1
    );
214
}
215