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
|
2 |
|
} |
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 string $domain Domain where to set character set |
62
|
|
|
* @param string $codeset Character set to set |
63
|
|
|
*/ |
64
|
|
|
function _bind_textdomain_codeset($domain, $codeset): void |
|
|
|
|
65
|
|
|
{ |
66
|
2 |
|
} |
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
|
2 |
|
} |
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($msgid); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Translates a string, alias for _gettext. |
92
|
|
|
* |
93
|
|
|
* @param string $msgid String to be translated |
94
|
|
|
* |
95
|
|
|
* @return string translated string (or original, if not found) |
96
|
|
|
*/ |
97
|
|
|
function __(string $msgid): string |
98
|
|
|
{ |
99
|
4 |
|
return Loader::getInstance()->getTranslator()->gettext($msgid); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* Plural version of gettext. |
104
|
|
|
* |
105
|
|
|
* @param string $msgid Single form |
106
|
|
|
* @param string $msgidPlural Plural form |
107
|
|
|
* @param int $number Number of objects |
108
|
|
|
* |
109
|
|
|
* @return string translated plural form |
110
|
|
|
*/ |
111
|
|
|
function _ngettext(string $msgid, string $msgidPlural, int $number): string |
112
|
|
|
{ |
113
|
4 |
|
return Loader::getInstance()->getTranslator()->ngettext($msgid, $msgidPlural, $number); |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* Translate with context. |
118
|
|
|
* |
119
|
|
|
* @param string $msgctxt Context |
120
|
|
|
* @param string $msgid String to be translated |
121
|
|
|
* |
122
|
|
|
* @return string translated plural form |
123
|
|
|
*/ |
124
|
|
|
function _pgettext(string $msgctxt, string $msgid): string |
125
|
|
|
{ |
126
|
4 |
|
return Loader::getInstance()->getTranslator()->pgettext($msgctxt, $msgid); |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* Plural version of pgettext. |
131
|
|
|
* |
132
|
|
|
* @param string $msgctxt Context |
133
|
|
|
* @param string $msgid Single form |
134
|
|
|
* @param string $msgidPlural Plural form |
135
|
|
|
* @param int $number Number of objects |
136
|
|
|
* |
137
|
|
|
* @return string translated plural form |
138
|
|
|
*/ |
139
|
|
|
function _npgettext(string $msgctxt, string $msgid, string $msgidPlural, int $number): string |
140
|
|
|
{ |
141
|
4 |
|
return Loader::getInstance()->getTranslator()->npgettext($msgctxt, $msgid, $msgidPlural, $number); |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* Translates a string. |
146
|
|
|
* |
147
|
|
|
* @param string $domain Domain to use |
148
|
|
|
* @param string $msgid String to be translated |
149
|
|
|
* |
150
|
|
|
* @return string translated string (or original, if not found) |
151
|
|
|
*/ |
152
|
|
|
function _dgettext(string $domain, string $msgid): string |
153
|
|
|
{ |
154
|
4 |
|
return Loader::getInstance()->getTranslator($domain)->gettext($msgid); |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
/** |
158
|
|
|
* Plural version of gettext. |
159
|
|
|
* |
160
|
|
|
* @param string $domain Domain to use |
161
|
|
|
* @param string $msgid Single form |
162
|
|
|
* @param string $msgidPlural Plural form |
163
|
|
|
* @param int $number Number of objects |
164
|
|
|
* |
165
|
|
|
* @return string translated plural form |
166
|
|
|
*/ |
167
|
|
|
function _dngettext(string $domain, string $msgid, string $msgidPlural, int $number): string |
168
|
|
|
{ |
169
|
4 |
|
return Loader::getInstance()->getTranslator($domain)->ngettext($msgid, $msgidPlural, $number); |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
/** |
173
|
|
|
* Translate with context. |
174
|
|
|
* |
175
|
|
|
* @param string $domain Domain to use |
176
|
|
|
* @param string $msgctxt Context |
177
|
|
|
* @param string $msgid String to be translated |
178
|
|
|
* |
179
|
|
|
* @return string translated plural form |
180
|
|
|
*/ |
181
|
|
|
function _dpgettext(string $domain, string $msgctxt, string $msgid): string |
182
|
|
|
{ |
183
|
4 |
|
return Loader::getInstance()->getTranslator($domain)->pgettext($msgctxt, $msgid); |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* Plural version of pgettext. |
188
|
|
|
* |
189
|
|
|
* @param string $domain Domain to use |
190
|
|
|
* @param string $msgctxt Context |
191
|
|
|
* @param string $msgid Single form |
192
|
|
|
* @param string $msgidPlural Plural form |
193
|
|
|
* @param int $number Number of objects |
194
|
|
|
* |
195
|
|
|
* @return string translated plural form |
196
|
|
|
*/ |
197
|
|
|
function _dnpgettext(string $domain, string $msgctxt, string $msgid, string $msgidPlural, int $number): string |
198
|
|
|
{ |
199
|
4 |
|
return Loader::getInstance()->getTranslator($domain)->npgettext($msgctxt, $msgid, $msgidPlural, $number); |
200
|
|
|
} |
201
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.