Completed
Push — master ( f38c7d...8cf83d )
by Michal
03:58
created
src/gettext.inc 3 patches
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 // LC_MESSAGES is not available if php-gettext is not loaded
36 36
 // while the other constants are already available from session extension.
37 37
 if (!defined('LC_MESSAGES')) {
38
-  define('LC_MESSAGES',	5);
38
+    define('LC_MESSAGES',	5);
39 39
 }
40 40
 
41 41
 
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
 
51 51
 /* Class to hold a single domain included in $text_domains. */
52 52
 class domain {
53
-  var $l10n;
54
-  var $path;
55
-  var $codeset;
53
+    var $l10n;
54
+    var $path;
55
+    var $codeset;
56 56
 }
57 57
 
58 58
 // Utility functions
@@ -61,50 +61,50 @@  discard block
 block discarded – undo
61 61
  * Return a list of locales to try for any POSIX-style locale specification.
62 62
  */
63 63
 function get_list_of_locales($locale) {
64
-  /* Figure out all possible locale names and start with the most
64
+    /* Figure out all possible locale names and start with the most
65 65
    * specific ones.  I.e. for sr_CS.UTF-8@latin, look through all of
66 66
    * sr_CS.UTF-8@latin, sr_CS@latin, sr@latin, sr_CS.UTF-8, sr_CS, sr.
67 67
    */
68
-  $locale_names = array();
69
-  $lang = NULL;
70
-  $country = NULL;
71
-  $charset = NULL;
72
-  $modifier = NULL;
73
-  if ($locale) {
68
+    $locale_names = array();
69
+    $lang = NULL;
70
+    $country = NULL;
71
+    $charset = NULL;
72
+    $modifier = NULL;
73
+    if ($locale) {
74 74
     if (preg_match("/^(?P<lang>[a-z]{2,3})"              // language code
75
-                   ."(?:_(?P<country>[A-Z]{2}))?"           // country code
76
-                   ."(?:\.(?P<charset>[-A-Za-z0-9_]+))?"    // charset
77
-                   ."(?:@(?P<modifier>[-A-Za-z0-9_]+))?$/",  // @ modifier
78
-                   $locale, $matches)) {
75
+                    ."(?:_(?P<country>[A-Z]{2}))?"           // country code
76
+                    ."(?:\.(?P<charset>[-A-Za-z0-9_]+))?"    // charset
77
+                    ."(?:@(?P<modifier>[-A-Za-z0-9_]+))?$/",  // @ modifier
78
+                    $locale, $matches)) {
79 79
 
80
-      if (isset($matches["lang"])) $lang = $matches["lang"];
81
-      if (isset($matches["country"])) $country = $matches["country"];
82
-      if (isset($matches["charset"])) $charset = $matches["charset"];
83
-      if (isset($matches["modifier"])) $modifier = $matches["modifier"];
80
+        if (isset($matches["lang"])) $lang = $matches["lang"];
81
+        if (isset($matches["country"])) $country = $matches["country"];
82
+        if (isset($matches["charset"])) $charset = $matches["charset"];
83
+        if (isset($matches["modifier"])) $modifier = $matches["modifier"];
84 84
 
85
-      if ($modifier) {
85
+        if ($modifier) {
86 86
         if ($country) {
87
-          if ($charset)
87
+            if ($charset)
88 88
             array_push($locale_names, "${lang}_$country.$charset@$modifier");
89
-          array_push($locale_names, "${lang}_$country@$modifier");
89
+            array_push($locale_names, "${lang}_$country@$modifier");
90 90
         } elseif ($charset)
91 91
             array_push($locale_names, "${lang}.$charset@$modifier");
92 92
         array_push($locale_names, "$lang@$modifier");
93
-      }
94
-      if ($country) {
93
+        }
94
+        if ($country) {
95 95
         if ($charset)
96
-          array_push($locale_names, "${lang}_$country.$charset");
96
+            array_push($locale_names, "${lang}_$country.$charset");
97 97
         array_push($locale_names, "${lang}_$country");
98
-      } elseif ($charset)
99
-          array_push($locale_names, "${lang}.$charset");
100
-      array_push($locale_names, $lang);
98
+        } elseif ($charset)
99
+            array_push($locale_names, "${lang}.$charset");
100
+        array_push($locale_names, $lang);
101 101
     }
102 102
 
103 103
     // If the locale name doesn't match POSIX style, just include it as-is.
104 104
     if (!in_array($locale, $locale_names))
105
-      array_push($locale_names, $locale);
106
-  }
107
-  return $locale_names;
105
+        array_push($locale_names, $locale);
106
+    }
107
+    return $locale_names;
108 108
 }
109 109
 
110 110
 /**
@@ -123,16 +123,16 @@  discard block
 block discarded – undo
123 123
         $locale_names = get_list_of_locales($locale);
124 124
         $input = null;
125 125
         foreach ($locale_names as $locale) {
126
-          $full_path = $bound_path . $locale . "/" . $subpath;
127
-          if (file_exists($full_path)) {
126
+            $full_path = $bound_path . $locale . "/" . $subpath;
127
+            if (file_exists($full_path)) {
128 128
             $input = new FileReader($full_path);
129 129
             break;
130
-          }
130
+            }
131 131
         }
132 132
 
133 133
         if (!array_key_exists($domain, $text_domains)) {
134
-          // Initialize an empty domain object.
135
-          $text_domains[$domain] = new domain();
134
+            // Initialize an empty domain object.
135
+            $text_domains[$domain] = new domain();
136 136
         }
137 137
         $text_domains[$domain]->l10n = new MoTranslator\MoTranslator($input);
138 138
     }
@@ -190,9 +190,9 @@  discard block
 block discarded – undo
190 190
  * Returns passed in $locale, or environment variable $LANG if $locale == ''.
191 191
  */
192 192
 function _get_default_locale($locale) {
193
-  if ($locale == '') // emulate variable support
193
+    if ($locale == '') // emulate variable support
194 194
     return getenv('LANG');
195
-  else
195
+    else
196 196
     return $locale;
197 197
 }
198 198
 
@@ -210,20 +210,20 @@  discard block
 block discarded – undo
210 210
             return _setlocale($category, $CURRENTLOCALE);
211 211
     } else {
212 212
         if (function_exists('setlocale')) {
213
-          $ret = setlocale($category, $locale);
214
-          if (($locale == '' and !$ret) or // failed setting it by env
213
+            $ret = setlocale($category, $locale);
214
+            if (($locale == '' and !$ret) or // failed setting it by env
215 215
               ($locale != '' and $ret != $locale)) { // failed setting it
216 216
             // Failed setting it according to environment.
217 217
             $CURRENTLOCALE = _get_default_locale($locale);
218 218
             $EMULATEGETTEXT = 1;
219
-          } else {
219
+            } else {
220 220
             $CURRENTLOCALE = $ret;
221 221
             $EMULATEGETTEXT = 0;
222
-          }
222
+            }
223 223
         } else {
224
-          // No function setlocale(), emulate it all.
225
-          $CURRENTLOCALE = _get_default_locale($locale);
226
-          $EMULATEGETTEXT = 1;
224
+            // No function setlocale(), emulate it all.
225
+            $CURRENTLOCALE = _get_default_locale($locale);
226
+            $EMULATEGETTEXT = 1;
227 227
         }
228 228
         // Allow locale to be changed on the go for one translation domain.
229 229
         global $text_domains, $default_domain;
@@ -241,15 +241,15 @@  discard block
 block discarded – undo
241 241
     global $text_domains;
242 242
     // ensure $path ends with a slash ('/' should work for both, but lets still play nice)
243 243
     if (DIRECTORY_SEPARATOR == '\\') {
244
-      if ($path[strlen($path)-1] != '\\' and $path[strlen($path)-1] != '/')
244
+        if ($path[strlen($path)-1] != '\\' and $path[strlen($path)-1] != '/')
245 245
         $path .= '\\';
246 246
     } else {
247
-      if ($path[strlen($path)-1] != '/')
247
+        if ($path[strlen($path)-1] != '/')
248 248
         $path .= '/';
249 249
     }
250 250
     if (!array_key_exists($domain, $text_domains)) {
251
-      // Initialize an empty domain object.
252
-      $text_domains[$domain] = new domain();
251
+        // Initialize an empty domain object.
252
+        $text_domains[$domain] = new domain();
253 253
     }
254 254
     $text_domains[$domain]->path = $path;
255 255
 }
@@ -317,8 +317,8 @@  discard block
 block discarded – undo
317 317
     return _encode($l10n->translate($msgid));
318 318
 }
319 319
 /**
320
- * Plural version of dcgettext.
321
- */
320
+     * Plural version of dcgettext.
321
+     */
322 322
 function _dcngettext($domain, $singular, $plural, $number, $category) {
323 323
     $l10n = _get_reader($domain, $category);
324 324
     return _encode($l10n->ngettext($singular, $plural, $number));
@@ -426,29 +426,29 @@  discard block
 block discarded – undo
426 426
 }
427 427
 function T_dcngettext($domain, $singular, $plural, $number, $category) {
428 428
     if (_check_locale_and_function())
429
-      return dcngettext($domain, $singular, $plural, $number, $category);
429
+        return dcngettext($domain, $singular, $plural, $number, $category);
430 430
     else return _dcngettext($domain, $singular, $plural, $number, $category);
431 431
 }
432 432
 
433 433
 function T_pgettext($context, $msgid) {
434
-  if (_check_locale_and_function('pgettext'))
435
-      return pgettext($context, $msgid);
436
-  else
437
-      return _pgettext($context, $msgid);
434
+    if (_check_locale_and_function('pgettext'))
435
+        return pgettext($context, $msgid);
436
+    else
437
+        return _pgettext($context, $msgid);
438 438
 }
439 439
 
440 440
 function T_dpgettext($domain, $context, $msgid) {
441
-  if (_check_locale_and_function('dpgettext'))
442
-      return dpgettext($domain, $context, $msgid);
443
-  else
444
-      return _dpgettext($domain, $context, $msgid);
441
+    if (_check_locale_and_function('dpgettext'))
442
+        return dpgettext($domain, $context, $msgid);
443
+    else
444
+        return _dpgettext($domain, $context, $msgid);
445 445
 }
446 446
 
447 447
 function T_dcpgettext($domain, $context, $msgid, $category) {
448
-  if (_check_locale_and_function('dcpgettext'))
449
-      return dcpgettext($domain, $context, $msgid, $category);
450
-  else
451
-      return _dcpgettext($domain, $context, $msgid, $category);
448
+    if (_check_locale_and_function('dcpgettext'))
449
+        return dcpgettext($domain, $context, $msgid, $category);
450
+    else
451
+        return _dcpgettext($domain, $context, $msgid, $category);
452 452
 }
453 453
 
454 454
 function T_npgettext($context, $singular, $plural, $number) {
@@ -459,17 +459,17 @@  discard block
 block discarded – undo
459 459
 }
460 460
 
461 461
 function T_dnpgettext($domain, $context, $singular, $plural, $number) {
462
-  if (_check_locale_and_function('dnpgettext'))
463
-      return dnpgettext($domain, $context, $singular, $plural, $number);
464
-  else
465
-      return _dnpgettext($domain, $context, $singular, $plural, $number);
462
+    if (_check_locale_and_function('dnpgettext'))
463
+        return dnpgettext($domain, $context, $singular, $plural, $number);
464
+    else
465
+        return _dnpgettext($domain, $context, $singular, $plural, $number);
466 466
 }
467 467
 
468 468
 function T_dcnpgettext($domain, $context, $singular, $plural,
469
-                       $number, $category) {
469
+                        $number, $category) {
470 470
     if (_check_locale_and_function('dcnpgettext'))
471 471
         return dcnpgettext($domain, $context, $singular,
472
-                           $plural, $number, $category);
472
+                            $plural, $number, $category);
473 473
     else
474 474
         return _dcnpgettext($domain, $context, $singular,
475 475
                             $plural, $number, $category);
@@ -526,9 +526,9 @@  discard block
 block discarded – undo
526 526
         return _dcpgettext($domain, $context, $msgid, $category);
527 527
     }
528 528
     function dcnpgettext($domain, $context, $singular, $plural,
529
-                         $number, $category) {
530
-      return _dcnpgettext($domain, $context, $singular, $plural,
531
-                          $number, $category);
529
+                            $number, $category) {
530
+        return _dcnpgettext($domain, $context, $singular, $plural,
531
+                            $number, $category);
532 532
     }
533 533
 }
534 534
 
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 // LC_MESSAGES is not available if php-gettext is not loaded
36 36
 // while the other constants are already available from session extension.
37 37
 if (!defined('LC_MESSAGES')) {
38
-  define('LC_MESSAGES',	5);
38
+  define('LC_MESSAGES', 5);
39 39
 }
40 40
 
41 41
 
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
     if (preg_match("/^(?P<lang>[a-z]{2,3})"              // language code
75 75
                    ."(?:_(?P<country>[A-Z]{2}))?"           // country code
76 76
                    ."(?:\.(?P<charset>[-A-Za-z0-9_]+))?"    // charset
77
-                   ."(?:@(?P<modifier>[-A-Za-z0-9_]+))?$/",  // @ modifier
77
+                   ."(?:@(?P<modifier>[-A-Za-z0-9_]+))?$/", // @ modifier
78 78
                    $locale, $matches)) {
79 79
 
80 80
       if (isset($matches["lang"])) $lang = $matches["lang"];
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 /**
111 111
  * Utility function to get a StreamReader for the given text domain.
112 112
  */
113
-function _get_reader($domain=null, $category=5) {
113
+function _get_reader($domain = null, $category = 5) {
114 114
     global $text_domains, $default_domain, $LC_CATEGORIES;
115 115
     if (!isset($domain)) $domain = $default_domain;
116 116
     if (!isset($text_domains[$domain]->l10n)) {
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
         $locale = _setlocale(LC_MESSAGES, 0);
119 119
         $bound_path = isset($text_domains[$domain]->path) ?
120 120
           $text_domains[$domain]->path : './';
121
-        $subpath = $LC_CATEGORIES[$category] ."/$domain.mo";
121
+        $subpath = $LC_CATEGORIES[$category] . "/$domain.mo";
122 122
 
123 123
         $locale_names = get_list_of_locales($locale);
124 124
         $input = null;
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 /**
151 151
  * Checks if the current locale is supported on this system.
152 152
  */
153
-function _check_locale_and_function($function=false) {
153
+function _check_locale_and_function($function = false) {
154 154
     global $EMULATEGETTEXT;
155 155
     if ($function and !function_exists($function))
156 156
         return false;
@@ -160,10 +160,10 @@  discard block
 block discarded – undo
160 160
 /**
161 161
  * Get the codeset for the given domain.
162 162
  */
163
-function _get_codeset($domain=null) {
163
+function _get_codeset($domain = null) {
164 164
     global $text_domains, $default_domain, $LC_CATEGORIES;
165 165
     if (!isset($domain)) $domain = $default_domain;
166
-    return (isset($text_domains[$domain]->codeset))? $text_domains[$domain]->codeset : ini_get('mbstring.internal_encoding');
166
+    return (isset($text_domains[$domain]->codeset)) ? $text_domains[$domain]->codeset : ini_get('mbstring.internal_encoding');
167 167
 }
168 168
 
169 169
 /**
@@ -241,10 +241,10 @@  discard block
 block discarded – undo
241 241
     global $text_domains;
242 242
     // ensure $path ends with a slash ('/' should work for both, but lets still play nice)
243 243
     if (DIRECTORY_SEPARATOR == '\\') {
244
-      if ($path[strlen($path)-1] != '\\' and $path[strlen($path)-1] != '/')
244
+      if ($path[strlen($path) - 1] != '\\' and $path[strlen($path) - 1] != '/')
245 245
         $path .= '\\';
246 246
     } else {
247
-      if ($path[strlen($path)-1] != '/')
247
+      if ($path[strlen($path) - 1] != '/')
248 248
         $path .= '/';
249 249
     }
250 250
     if (!array_key_exists($domain, $text_domains)) {
Please login to merge, or discard this patch.
Braces   +147 added lines, -95 removed lines patch added patch discarded remove patch
@@ -77,32 +77,45 @@  discard block
 block discarded – undo
77 77
                    ."(?:@(?P<modifier>[-A-Za-z0-9_]+))?$/",  // @ modifier
78 78
                    $locale, $matches)) {
79 79
 
80
-      if (isset($matches["lang"])) $lang = $matches["lang"];
81
-      if (isset($matches["country"])) $country = $matches["country"];
82
-      if (isset($matches["charset"])) $charset = $matches["charset"];
83
-      if (isset($matches["modifier"])) $modifier = $matches["modifier"];
80
+      if (isset($matches["lang"])) {
81
+          $lang = $matches["lang"];
82
+      }
83
+      if (isset($matches["country"])) {
84
+          $country = $matches["country"];
85
+      }
86
+      if (isset($matches["charset"])) {
87
+          $charset = $matches["charset"];
88
+      }
89
+      if (isset($matches["modifier"])) {
90
+          $modifier = $matches["modifier"];
91
+      }
84 92
 
85 93
       if ($modifier) {
86 94
         if ($country) {
87
-          if ($charset)
88
-            array_push($locale_names, "${lang}_$country.$charset@$modifier");
95
+          if ($charset) {
96
+                      array_push($locale_names, "${lang}_$country.$charset@$modifier");
97
+          }
89 98
           array_push($locale_names, "${lang}_$country@$modifier");
90
-        } elseif ($charset)
91
-            array_push($locale_names, "${lang}.$charset@$modifier");
99
+        } elseif ($charset) {
100
+                    array_push($locale_names, "${lang}.$charset@$modifier");
101
+        }
92 102
         array_push($locale_names, "$lang@$modifier");
93 103
       }
94 104
       if ($country) {
95
-        if ($charset)
96
-          array_push($locale_names, "${lang}_$country.$charset");
105
+        if ($charset) {
106
+                  array_push($locale_names, "${lang}_$country.$charset");
107
+        }
97 108
         array_push($locale_names, "${lang}_$country");
98
-      } elseif ($charset)
99
-          array_push($locale_names, "${lang}.$charset");
109
+      } elseif ($charset) {
110
+                array_push($locale_names, "${lang}.$charset");
111
+      }
100 112
       array_push($locale_names, $lang);
101 113
     }
102 114
 
103 115
     // If the locale name doesn't match POSIX style, just include it as-is.
104
-    if (!in_array($locale, $locale_names))
105
-      array_push($locale_names, $locale);
116
+    if (!in_array($locale, $locale_names)) {
117
+          array_push($locale_names, $locale);
118
+    }
106 119
   }
107 120
   return $locale_names;
108 121
 }
@@ -112,7 +125,9 @@  discard block
 block discarded – undo
112 125
  */
113 126
 function _get_reader($domain=null, $category=5) {
114 127
     global $text_domains, $default_domain, $LC_CATEGORIES;
115
-    if (!isset($domain)) $domain = $default_domain;
128
+    if (!isset($domain)) {
129
+        $domain = $default_domain;
130
+    }
116 131
     if (!isset($text_domains[$domain]->l10n)) {
117 132
         // get the current locale
118 133
         $locale = _setlocale(LC_MESSAGES, 0);
@@ -152,8 +167,9 @@  discard block
 block discarded – undo
152 167
  */
153 168
 function _check_locale_and_function($function=false) {
154 169
     global $EMULATEGETTEXT;
155
-    if ($function and !function_exists($function))
156
-        return false;
170
+    if ($function and !function_exists($function)) {
171
+            return false;
172
+    }
157 173
     return !$EMULATEGETTEXT;
158 174
 }
159 175
 
@@ -162,7 +178,9 @@  discard block
 block discarded – undo
162 178
  */
163 179
 function _get_codeset($domain=null) {
164 180
     global $text_domains, $default_domain, $LC_CATEGORIES;
165
-    if (!isset($domain)) $domain = $default_domain;
181
+    if (!isset($domain)) {
182
+        $domain = $default_domain;
183
+    }
166 184
     return (isset($text_domains[$domain]->codeset))? $text_domains[$domain]->codeset : ini_get('mbstring.internal_encoding');
167 185
 }
168 186
 
@@ -177,8 +195,7 @@  discard block
 block discarded – undo
177 195
     $target_encoding = _get_codeset();
178 196
     if ($source_encoding != $target_encoding) {
179 197
         return mb_convert_encoding($text, $target_encoding, $source_encoding);
180
-    }
181
-    else {
198
+    } else {
182 199
         return $text;
183 200
     }
184 201
 }
@@ -190,11 +207,13 @@  discard block
 block discarded – undo
190 207
  * Returns passed in $locale, or environment variable $LANG if $locale == ''.
191 208
  */
192 209
 function _get_default_locale($locale) {
193
-  if ($locale == '') // emulate variable support
210
+  if ($locale == '') {
211
+      // emulate variable support
194 212
     return getenv('LANG');
195
-  else
196
-    return $locale;
197
-}
213
+  } else {
214
+      return $locale;
215
+  }
216
+  }
198 217
 
199 218
 /**
200 219
  * Sets a requested locale, if needed emulates it.
@@ -202,12 +221,13 @@  discard block
 block discarded – undo
202 221
 function _setlocale($category, $locale) {
203 222
     global $CURRENTLOCALE, $EMULATEGETTEXT;
204 223
     if ($locale === 0) { // use === to differentiate between string "0"
205
-        if ($CURRENTLOCALE != '')
206
-            return $CURRENTLOCALE;
207
-        else
208
-            // obey LANG variable, maybe extend to support all of LC_* vars
224
+        if ($CURRENTLOCALE != '') {
225
+                    return $CURRENTLOCALE;
226
+        } else {
227
+                    // obey LANG variable, maybe extend to support all of LC_* vars
209 228
             // even if we tried to read locale without setting it first
210 229
             return _setlocale($category, $CURRENTLOCALE);
230
+        }
211 231
     } else {
212 232
         if (function_exists('setlocale')) {
213 233
           $ret = setlocale($category, $locale);
@@ -241,11 +261,13 @@  discard block
 block discarded – undo
241 261
     global $text_domains;
242 262
     // ensure $path ends with a slash ('/' should work for both, but lets still play nice)
243 263
     if (DIRECTORY_SEPARATOR == '\\') {
244
-      if ($path[strlen($path)-1] != '\\' and $path[strlen($path)-1] != '/')
245
-        $path .= '\\';
264
+      if ($path[strlen($path)-1] != '\\' and $path[strlen($path)-1] != '/') {
265
+              $path .= '\\';
266
+      }
246 267
     } else {
247
-      if ($path[strlen($path)-1] != '/')
248
-        $path .= '/';
268
+      if ($path[strlen($path)-1] != '/') {
269
+              $path .= '/';
270
+      }
249 271
     }
250 272
     if (!array_key_exists($domain, $text_domains)) {
251 273
       // Initialize an empty domain object.
@@ -384,96 +406,126 @@  discard block
 block discarded – undo
384 406
 }
385 407
 
386 408
 function T_bindtextdomain($domain, $path) {
387
-    if (_check_locale_and_function()) return bindtextdomain($domain, $path);
388
-    else return _bindtextdomain($domain, $path);
389
-}
409
+    if (_check_locale_and_function()) {
410
+        return bindtextdomain($domain, $path);
411
+    } else {
412
+        return _bindtextdomain($domain, $path);
413
+    }
414
+    }
390 415
 function T_bind_textdomain_codeset($domain, $codeset) {
391 416
     // bind_textdomain_codeset is available only in PHP 4.2.0+
392
-    if (_check_locale_and_function('bind_textdomain_codeset'))
393
-        return bind_textdomain_codeset($domain, $codeset);
394
-    else return _bind_textdomain_codeset($domain, $codeset);
395
-}
417
+    if (_check_locale_and_function('bind_textdomain_codeset')) {
418
+            return bind_textdomain_codeset($domain, $codeset);
419
+    } else {
420
+        return _bind_textdomain_codeset($domain, $codeset);
421
+    }
422
+    }
396 423
 function T_textdomain($domain) {
397
-    if (_check_locale_and_function()) return textdomain($domain);
398
-    else return _textdomain($domain);
399
-}
424
+    if (_check_locale_and_function()) {
425
+        return textdomain($domain);
426
+    } else {
427
+        return _textdomain($domain);
428
+    }
429
+    }
400 430
 function T_gettext($msgid) {
401
-    if (_check_locale_and_function()) return gettext($msgid);
402
-    else return _gettext($msgid);
403
-}
431
+    if (_check_locale_and_function()) {
432
+        return gettext($msgid);
433
+    } else {
434
+        return _gettext($msgid);
435
+    }
436
+    }
404 437
 function T_($msgid) {
405
-    if (_check_locale_and_function()) return _($msgid);
438
+    if (_check_locale_and_function()) {
439
+        return _($msgid);
440
+    }
406 441
     return __($msgid);
407 442
 }
408 443
 function T_ngettext($singular, $plural, $number) {
409
-    if (_check_locale_and_function())
410
-        return ngettext($singular, $plural, $number);
411
-    else return _ngettext($singular, $plural, $number);
412
-}
444
+    if (_check_locale_and_function()) {
445
+            return ngettext($singular, $plural, $number);
446
+    } else {
447
+        return _ngettext($singular, $plural, $number);
448
+    }
449
+    }
413 450
 function T_dgettext($domain, $msgid) {
414
-    if (_check_locale_and_function()) return dgettext($domain, $msgid);
415
-    else return _dgettext($domain, $msgid);
416
-}
451
+    if (_check_locale_and_function()) {
452
+        return dgettext($domain, $msgid);
453
+    } else {
454
+        return _dgettext($domain, $msgid);
455
+    }
456
+    }
417 457
 function T_dngettext($domain, $singular, $plural, $number) {
418
-    if (_check_locale_and_function())
419
-        return dngettext($domain, $singular, $plural, $number);
420
-    else return _dngettext($domain, $singular, $plural, $number);
421
-}
458
+    if (_check_locale_and_function()) {
459
+            return dngettext($domain, $singular, $plural, $number);
460
+    } else {
461
+        return _dngettext($domain, $singular, $plural, $number);
462
+    }
463
+    }
422 464
 function T_dcgettext($domain, $msgid, $category) {
423
-    if (_check_locale_and_function())
424
-        return dcgettext($domain, $msgid, $category);
425
-    else return _dcgettext($domain, $msgid, $category);
426
-}
465
+    if (_check_locale_and_function()) {
466
+            return dcgettext($domain, $msgid, $category);
467
+    } else {
468
+        return _dcgettext($domain, $msgid, $category);
469
+    }
470
+    }
427 471
 function T_dcngettext($domain, $singular, $plural, $number, $category) {
428
-    if (_check_locale_and_function())
429
-      return dcngettext($domain, $singular, $plural, $number, $category);
430
-    else return _dcngettext($domain, $singular, $plural, $number, $category);
431
-}
472
+    if (_check_locale_and_function()) {
473
+          return dcngettext($domain, $singular, $plural, $number, $category);
474
+    } else {
475
+        return _dcngettext($domain, $singular, $plural, $number, $category);
476
+    }
477
+    }
432 478
 
433 479
 function T_pgettext($context, $msgid) {
434
-  if (_check_locale_and_function('pgettext'))
435
-      return pgettext($context, $msgid);
436
-  else
437
-      return _pgettext($context, $msgid);
438
-}
480
+  if (_check_locale_and_function('pgettext')) {
481
+        return pgettext($context, $msgid);
482
+  } else {
483
+        return _pgettext($context, $msgid);
484
+  }
485
+  }
439 486
 
440 487
 function T_dpgettext($domain, $context, $msgid) {
441
-  if (_check_locale_and_function('dpgettext'))
442
-      return dpgettext($domain, $context, $msgid);
443
-  else
444
-      return _dpgettext($domain, $context, $msgid);
445
-}
488
+  if (_check_locale_and_function('dpgettext')) {
489
+        return dpgettext($domain, $context, $msgid);
490
+  } else {
491
+        return _dpgettext($domain, $context, $msgid);
492
+  }
493
+  }
446 494
 
447 495
 function T_dcpgettext($domain, $context, $msgid, $category) {
448
-  if (_check_locale_and_function('dcpgettext'))
449
-      return dcpgettext($domain, $context, $msgid, $category);
450
-  else
451
-      return _dcpgettext($domain, $context, $msgid, $category);
452
-}
496
+  if (_check_locale_and_function('dcpgettext')) {
497
+        return dcpgettext($domain, $context, $msgid, $category);
498
+  } else {
499
+        return _dcpgettext($domain, $context, $msgid, $category);
500
+  }
501
+  }
453 502
 
454 503
 function T_npgettext($context, $singular, $plural, $number) {
455
-    if (_check_locale_and_function('npgettext'))
456
-        return npgettext($context, $singular, $plural, $number);
457
-    else
458
-        return _npgettext($context, $singular, $plural, $number);
459
-}
504
+    if (_check_locale_and_function('npgettext')) {
505
+            return npgettext($context, $singular, $plural, $number);
506
+    } else {
507
+            return _npgettext($context, $singular, $plural, $number);
508
+    }
509
+    }
460 510
 
461 511
 function T_dnpgettext($domain, $context, $singular, $plural, $number) {
462
-  if (_check_locale_and_function('dnpgettext'))
463
-      return dnpgettext($domain, $context, $singular, $plural, $number);
464
-  else
465
-      return _dnpgettext($domain, $context, $singular, $plural, $number);
466
-}
512
+  if (_check_locale_and_function('dnpgettext')) {
513
+        return dnpgettext($domain, $context, $singular, $plural, $number);
514
+  } else {
515
+        return _dnpgettext($domain, $context, $singular, $plural, $number);
516
+  }
517
+  }
467 518
 
468 519
 function T_dcnpgettext($domain, $context, $singular, $plural,
469 520
                        $number, $category) {
470
-    if (_check_locale_and_function('dcnpgettext'))
471
-        return dcnpgettext($domain, $context, $singular,
521
+    if (_check_locale_and_function('dcnpgettext')) {
522
+            return dcnpgettext($domain, $context, $singular,
472 523
                            $plural, $number, $category);
473
-    else
474
-        return _dcnpgettext($domain, $context, $singular,
524
+    } else {
525
+            return _dcnpgettext($domain, $context, $singular,
475 526
                             $plural, $number, $category);
476
-}
527
+    }
528
+    }
477 529
 
478 530
 
479 531
 
Please login to merge, or discard this patch.
src/MoTranslator.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
      */
60 60
     public function __construct($filename)
61 61
     {
62
-        if (! is_readable($filename)) {
62
+        if (!is_readable($filename)) {
63 63
             $this->error = 2; // file does not exist
64 64
             return;
65 65
         }
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
         $expr = explode(';', $expr, 2);
123 123
         if (count($expr) == 2) {
124 124
             $expr = $expr[1];
125
-        } else{
125
+        } else {
126 126
             $expr = $expr[0];
127 127
         }
128 128
         $expr = preg_replace('@[^a-zA-Z0-9_:;\(\)\?\|\&=!<>+*/\%-]@', '', $expr);
@@ -142,15 +142,15 @@  discard block
 block discarded – undo
142 142
                     $res .= ') : (';
143 143
                     break;
144 144
                 case ';':
145
-                    $res .= str_repeat( ')', $p) . ';';
145
+                    $res .= str_repeat(')', $p) . ';';
146 146
                     $p = 0;
147 147
                     break;
148 148
                 default:
149 149
                     $res .= $ch;
150 150
             }
151 151
         }
152
-        $res = str_replace('n','$n',$res);
153
-        $res = str_replace('plural','$plural',$res);
152
+        $res = str_replace('n', '$n', $res);
153
+        $res = str_replace('plural', '$plural', $res);
154 154
         return $res;
155 155
     }
156 156
 
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
     {
244 244
         // this should contains all strings separated by NULLs
245 245
         $key = implode(chr(0), array($single, $plural));
246
-        if (! array_key_exists($key, $this->cache_translations)) {
246
+        if (!array_key_exists($key, $this->cache_translations)) {
247 247
             return ($number != 1) ? $plural : $single;
248 248
         }
249 249
 
Please login to merge, or discard this patch.