@@ -140,8 +140,9 @@ discard block |
||
140 | 140 | function load_tables() { |
141 | 141 | if (is_array($this->cache_translations) && |
142 | 142 | is_array($this->table_originals) && |
143 | - is_array($this->table_translations)) |
|
144 | - return; |
|
143 | + is_array($this->table_translations)) { |
|
144 | + return; |
|
145 | + } |
|
145 | 146 | |
146 | 147 | /* get original and translations tables */ |
147 | 148 | if (!is_array($this->table_originals)) { |
@@ -176,8 +177,9 @@ discard block |
||
176 | 177 | function get_original_string($num) { |
177 | 178 | $length = $this->table_originals[$num * 2 + 1]; |
178 | 179 | $offset = $this->table_originals[$num * 2 + 2]; |
179 | - if (! $length) |
|
180 | - return ''; |
|
180 | + if (! $length) { |
|
181 | + return ''; |
|
182 | + } |
|
181 | 183 | $this->STREAM->seekto($offset); |
182 | 184 | $data = $this->STREAM->read($length); |
183 | 185 | return (string)$data; |
@@ -193,8 +195,9 @@ discard block |
||
193 | 195 | function get_translation_string($num) { |
194 | 196 | $length = $this->table_translations[$num * 2 + 1]; |
195 | 197 | $offset = $this->table_translations[$num * 2 + 2]; |
196 | - if (! $length) |
|
197 | - return ''; |
|
198 | + if (! $length) { |
|
199 | + return ''; |
|
200 | + } |
|
198 | 201 | $this->STREAM->seekto($offset); |
199 | 202 | $data = $this->STREAM->read($length); |
200 | 203 | return (string)$data; |
@@ -218,10 +221,11 @@ discard block |
||
218 | 221 | if (abs($start - $end) <= 1) { |
219 | 222 | // We're done, now we either found the string, or it doesn't exist |
220 | 223 | $txt = $this->get_original_string($start); |
221 | - if ($string == $txt) |
|
222 | - return $start; |
|
223 | - else |
|
224 | - return -1; |
|
224 | + if ($string == $txt) { |
|
225 | + return $start; |
|
226 | + } else { |
|
227 | + return -1; |
|
228 | + } |
|
225 | 229 | } else if ($start > $end) { |
226 | 230 | // start > end -> turn around and start over |
227 | 231 | return $this->find_string($string, $end, $start); |
@@ -229,15 +233,16 @@ discard block |
||
229 | 233 | // Divide table in two parts |
230 | 234 | $half = (int)(($start + $end) / 2); |
231 | 235 | $cmp = strcmp($string, $this->get_original_string($half)); |
232 | - if ($cmp == 0) |
|
233 | - // string is exactly in the middle => return it |
|
236 | + if ($cmp == 0) { |
|
237 | + // string is exactly in the middle => return it |
|
234 | 238 | return $half; |
235 | - else if ($cmp < 0) |
|
236 | - // The string is in the upper half |
|
239 | + } else if ($cmp < 0) { |
|
240 | + // The string is in the upper half |
|
237 | 241 | return $this->find_string($string, $start, $half); |
238 | - else |
|
239 | - // The string is in the lower half |
|
242 | + } else { |
|
243 | + // The string is in the lower half |
|
240 | 244 | return $this->find_string($string, $half, $end); |
245 | + } |
|
241 | 246 | } |
242 | 247 | } |
243 | 248 | |
@@ -249,23 +254,26 @@ discard block |
||
249 | 254 | * @return string translated string (or original, if not found) |
250 | 255 | */ |
251 | 256 | function translate($string) { |
252 | - if ($this->short_circuit) |
|
253 | - return $string; |
|
257 | + if ($this->short_circuit) { |
|
258 | + return $string; |
|
259 | + } |
|
254 | 260 | $this->load_tables(); |
255 | 261 | |
256 | 262 | if ($this->enable_cache) { |
257 | 263 | // Caching enabled, get translated string from cache |
258 | - if (array_key_exists($string, $this->cache_translations)) |
|
259 | - return $this->cache_translations[$string]; |
|
260 | - else |
|
261 | - return $string; |
|
264 | + if (array_key_exists($string, $this->cache_translations)) { |
|
265 | + return $this->cache_translations[$string]; |
|
266 | + } else { |
|
267 | + return $string; |
|
268 | + } |
|
262 | 269 | } else { |
263 | 270 | // Caching not enabled, try to find string |
264 | 271 | $num = $this->find_string($string); |
265 | - if ($num == -1) |
|
266 | - return $string; |
|
267 | - else |
|
268 | - return $this->get_translation_string($num); |
|
272 | + if ($num == -1) { |
|
273 | + return $string; |
|
274 | + } else { |
|
275 | + return $this->get_translation_string($num); |
|
276 | + } |
|
269 | 277 | } |
270 | 278 | } |
271 | 279 | |
@@ -311,10 +319,11 @@ discard block |
||
311 | 319 | * @return string verbatim plural form header field |
312 | 320 | */ |
313 | 321 | function extract_plural_forms_header_from_po_header($header) { |
314 | - if (preg_match("/(^|\n)plural-forms: ([^\n]*)\n/i", $header, $regs)) |
|
315 | - $expr = $regs[2]; |
|
316 | - else |
|
317 | - $expr = "nplurals=2; plural=n == 1 ? 0 : 1;"; |
|
322 | + if (preg_match("/(^|\n)plural-forms: ([^\n]*)\n/i", $header, $regs)) { |
|
323 | + $expr = $regs[2]; |
|
324 | + } else { |
|
325 | + $expr = "nplurals=2; plural=n == 1 ? 0 : 1;"; |
|
326 | + } |
|
318 | 327 | return $expr; |
319 | 328 | } |
320 | 329 | |
@@ -363,7 +372,9 @@ discard block |
||
363 | 372 | $plural = 0; |
364 | 373 | |
365 | 374 | eval("$string"); |
366 | - if ($plural >= $total) $plural = $total - 1; |
|
375 | + if ($plural >= $total) { |
|
376 | + $plural = $total - 1; |
|
377 | + } |
|
367 | 378 | return $plural; |
368 | 379 | } |
369 | 380 | |
@@ -378,10 +389,11 @@ discard block |
||
378 | 389 | */ |
379 | 390 | function ngettext($single, $plural, $number) { |
380 | 391 | if ($this->short_circuit) { |
381 | - if ($number != 1) |
|
382 | - return $plural; |
|
383 | - else |
|
384 | - return $single; |
|
392 | + if ($number != 1) { |
|
393 | + return $plural; |
|
394 | + } else { |
|
395 | + return $single; |
|
396 | + } |
|
385 | 397 | } |
386 | 398 | |
387 | 399 | // find out the appropriate form |
@@ -15,8 +15,9 @@ |
||
15 | 15 | |
16 | 16 | global $fetch_last_error_content; |
17 | 17 | |
18 | - if (!$res && $fetch_last_error_content) |
|
19 | - $res = $fetch_last_error_content; |
|
18 | + if (!$res && $fetch_last_error_content) { |
|
19 | + $res = $fetch_last_error_content; |
|
20 | + } |
|
20 | 21 | |
21 | 22 | $doc = new DOMDocument(); |
22 | 23 |
@@ -19,7 +19,9 @@ |
||
19 | 19 | require_once "config.php"; |
20 | 20 | require_once "db-prefs.php"; |
21 | 21 | |
22 | - if (!init_plugins()) return; |
|
22 | + if (!init_plugins()) { |
|
23 | + return; |
|
24 | + } |
|
23 | 25 | |
24 | 26 | login_sequence(); |
25 | 27 |