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 | // phpcs:disable Squiz.Functions.GlobalFunction |
||||||
30 | |||||||
31 | if (! function_exists('_setlocale')) { |
||||||
32 | /** |
||||||
33 | * Sets a requested locale. |
||||||
34 | * |
||||||
35 | * @param int $category Locale category, ignored |
||||||
36 | * @param string $locale Locale name |
||||||
37 | * |
||||||
38 | * @return string Set or current locale |
||||||
39 | 28 | */ |
|||||
40 | function _setlocale(int $category, string $locale): string |
||||||
0 ignored issues
–
show
|
|||||||
41 | { |
||||||
42 | return Loader::getInstance()->setlocale($locale); |
||||||
43 | } |
||||||
44 | } |
||||||
45 | |||||||
46 | if (! function_exists('_bindtextdomain')) { |
||||||
47 | /** |
||||||
48 | * Sets the path for a domain. |
||||||
49 | * |
||||||
50 | 28 | * @param string $domain Domain name |
|||||
51 | 4 | * @param string $path Path where to find locales |
|||||
52 | */ |
||||||
53 | function _bindtextdomain(string $domain, string $path): void |
||||||
54 | { |
||||||
55 | Loader::getInstance()->bindtextdomain($domain, $path); |
||||||
56 | } |
||||||
57 | } |
||||||
58 | |||||||
59 | if (! function_exists('_bind_textdomain_codeset')) { |
||||||
60 | /** |
||||||
61 | * Dummy compatibility function, MoTranslator assumes |
||||||
62 | * everything is using same character set on input and |
||||||
63 | * output. |
||||||
64 | * |
||||||
65 | * Generally it is wise to output in UTF-8 and have |
||||||
66 | 28 | * mo files in UTF-8. |
|||||
67 | * |
||||||
68 | * @param string $domain Domain where to set character set |
||||||
69 | * @param string $codeset Character set to set |
||||||
70 | */ |
||||||
71 | function _bind_textdomain_codeset(string $domain, string $codeset): void |
||||||
0 ignored issues
–
show
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
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() 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
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||||
72 | { |
||||||
73 | } |
||||||
74 | } |
||||||
75 | 28 | ||||||
76 | 4 | if (! function_exists('_textdomain')) { |
|||||
77 | /** |
||||||
78 | * Sets the default domain. |
||||||
79 | * |
||||||
80 | * @param string $domain Domain name |
||||||
81 | */ |
||||||
82 | function _textdomain(string $domain): void |
||||||
83 | { |
||||||
84 | Loader::getInstance()->textdomain($domain); |
||||||
85 | } |
||||||
86 | } |
||||||
87 | 14 | ||||||
88 | if (! function_exists('_gettext')) { |
||||||
89 | /** |
||||||
90 | * Translates a string. |
||||||
91 | * |
||||||
92 | * @param string $msgid String to be translated |
||||||
93 | * |
||||||
94 | * @return string translated string (or original, if not found) |
||||||
95 | */ |
||||||
96 | function _gettext(string $msgid): string |
||||||
97 | { |
||||||
98 | return Loader::getInstance()->getTranslator()->gettext($msgid); |
||||||
99 | 14 | } |
|||||
100 | } |
||||||
101 | |||||||
102 | if (! function_exists('__')) { |
||||||
103 | /** |
||||||
104 | * Translates a string, alias for _gettext. |
||||||
105 | * |
||||||
106 | * @param string $msgid String to be translated |
||||||
107 | * |
||||||
108 | * @return string translated string (or original, if not found) |
||||||
109 | */ |
||||||
110 | function __(string $msgid): string |
||||||
111 | { |
||||||
112 | return Loader::getInstance()->getTranslator()->gettext($msgid); |
||||||
113 | 14 | } |
|||||
114 | } |
||||||
115 | |||||||
116 | if (! function_exists('_ngettext')) { |
||||||
117 | /** |
||||||
118 | * Plural version of gettext. |
||||||
119 | * |
||||||
120 | * @param string $msgid Single form |
||||||
121 | * @param string $msgidPlural Plural form |
||||||
122 | * @param int $number Number of objects |
||||||
123 | * |
||||||
124 | * @return string translated plural form |
||||||
125 | */ |
||||||
126 | 14 | function _ngettext(string $msgid, string $msgidPlural, int $number): string |
|||||
127 | { |
||||||
128 | return Loader::getInstance()->getTranslator()->ngettext($msgid, $msgidPlural, $number); |
||||||
129 | } |
||||||
130 | } |
||||||
131 | |||||||
132 | if (! function_exists('_pgettext')) { |
||||||
133 | /** |
||||||
134 | * Translate with context. |
||||||
135 | * |
||||||
136 | * @param string $msgctxt Context |
||||||
137 | * @param string $msgid String to be translated |
||||||
138 | * |
||||||
139 | * @return string translated plural form |
||||||
140 | */ |
||||||
141 | 14 | function _pgettext(string $msgctxt, string $msgid): string |
|||||
142 | { |
||||||
143 | return Loader::getInstance()->getTranslator()->pgettext($msgctxt, $msgid); |
||||||
144 | } |
||||||
145 | } |
||||||
146 | |||||||
147 | if (! function_exists('_npgettext')) { |
||||||
148 | /** |
||||||
149 | * Plural version of pgettext. |
||||||
150 | * |
||||||
151 | * @param string $msgctxt Context |
||||||
152 | * @param string $msgid Single form |
||||||
153 | * @param string $msgidPlural Plural form |
||||||
154 | 14 | * @param int $number Number of objects |
|||||
155 | * |
||||||
156 | * @return string translated plural form |
||||||
157 | */ |
||||||
158 | function _npgettext(string $msgctxt, string $msgid, string $msgidPlural, int $number): string |
||||||
159 | { |
||||||
160 | return Loader::getInstance()->getTranslator()->npgettext($msgctxt, $msgid, $msgidPlural, $number); |
||||||
161 | } |
||||||
162 | } |
||||||
163 | |||||||
164 | if (! function_exists('_dgettext')) { |
||||||
165 | /** |
||||||
166 | * Translates a string. |
||||||
167 | * |
||||||
168 | * @param string $domain Domain to use |
||||||
169 | 14 | * @param string $msgid String to be translated |
|||||
170 | * |
||||||
171 | * @return string translated string (or original, if not found) |
||||||
172 | */ |
||||||
173 | function _dgettext(string $domain, string $msgid): string |
||||||
174 | { |
||||||
175 | return Loader::getInstance()->getTranslator($domain)->gettext($msgid); |
||||||
176 | } |
||||||
177 | } |
||||||
178 | |||||||
179 | if (! function_exists('_dngettext')) { |
||||||
180 | /** |
||||||
181 | * Plural version of gettext. |
||||||
182 | * |
||||||
183 | 14 | * @param string $domain Domain to use |
|||||
184 | * @param string $msgid Single form |
||||||
185 | * @param string $msgidPlural Plural form |
||||||
186 | * @param int $number Number of objects |
||||||
187 | * |
||||||
188 | * @return string translated plural form |
||||||
189 | */ |
||||||
190 | function _dngettext(string $domain, string $msgid, string $msgidPlural, int $number): string |
||||||
191 | { |
||||||
192 | return Loader::getInstance()->getTranslator($domain)->ngettext($msgid, $msgidPlural, $number); |
||||||
193 | } |
||||||
194 | } |
||||||
195 | |||||||
196 | if (! function_exists('_dpgettext')) { |
||||||
197 | /** |
||||||
198 | * Translate with context. |
||||||
199 | 14 | * |
|||||
200 | * @param string $domain Domain to use |
||||||
201 | * @param string $msgctxt Context |
||||||
202 | * @param string $msgid String to be translated |
||||||
203 | * |
||||||
204 | * @return string translated plural form |
||||||
205 | */ |
||||||
206 | function _dpgettext(string $domain, string $msgctxt, string $msgid): string |
||||||
207 | { |
||||||
208 | return Loader::getInstance()->getTranslator($domain)->pgettext($msgctxt, $msgid); |
||||||
209 | } |
||||||
210 | } |
||||||
211 | |||||||
212 | if (! function_exists('_dnpgettext')) { |
||||||
213 | /** |
||||||
214 | * Plural version of pgettext. |
||||||
215 | * |
||||||
216 | * @param string $domain Domain to use |
||||||
217 | * @param string $msgctxt Context |
||||||
218 | * @param string $msgid Single form |
||||||
219 | * @param string $msgidPlural Plural form |
||||||
220 | * @param int $number Number of objects |
||||||
221 | * |
||||||
222 | * @return string translated plural form |
||||||
223 | */ |
||||||
224 | function _dnpgettext(string $domain, string $msgctxt, string $msgid, string $msgidPlural, int $number): string |
||||||
225 | { |
||||||
226 | return Loader::getInstance()->getTranslator($domain)->npgettext($msgctxt, $msgid, $msgidPlural, $number); |
||||||
227 | } |
||||||
228 | } |
||||||
229 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.