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 |
|
|
|
|
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 |
|
|
|
|
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
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.