@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | * @param string $plural Plural form |
| 205 | 205 | * @param string $number Number of objects |
| 206 | 206 | * |
| 207 | - * @return translated plural form |
|
| 207 | + * @return string plural form |
|
| 208 | 208 | */ |
| 209 | 209 | public function ngettext($single, $plural, $number) |
| 210 | 210 | { |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | * @param string $context Context |
| 229 | 229 | * @param string $msgid String to be translated |
| 230 | 230 | * |
| 231 | - * @return translated plural form |
|
| 231 | + * @return string plural form |
|
| 232 | 232 | */ |
| 233 | 233 | public function pgettext($context, $msgid) |
| 234 | 234 | { |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | * Plural version of pgettext |
| 246 | 246 | * |
| 247 | 247 | * @param string $context Context |
| 248 | - * @param string $single Single form |
|
| 248 | + * @param string $singular Single form |
|
| 249 | 249 | * @param string $plural Plural form |
| 250 | 250 | * @param string $number Number of objects |
| 251 | 251 | * |
@@ -40,8 +40,8 @@ discard block |
||
| 40 | 40 | public $error = 0; |
| 41 | 41 | |
| 42 | 42 | //private: |
| 43 | - private $pluralheader = NULL; // cache header field for plural forms |
|
| 44 | - private $cache_translations = array(); // original -> translation mapping |
|
| 43 | + private $pluralheader = NULL; // cache header field for plural forms |
|
| 44 | + private $cache_translations = array(); // original -> translation mapping |
|
| 45 | 45 | |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | */ |
| 52 | 52 | public function __construct($filename) |
| 53 | 53 | { |
| 54 | - if (! is_readable($filename)) { |
|
| 54 | + if (!is_readable($filename)) { |
|
| 55 | 55 | $this->error = 2; // file does not exist |
| 56 | 56 | return; |
| 57 | 57 | } |
@@ -128,16 +128,16 @@ discard block |
||
| 128 | 128 | $res .= ') : ('; |
| 129 | 129 | break; |
| 130 | 130 | case ';': |
| 131 | - $res .= str_repeat( ')', $p) . ';'; |
|
| 131 | + $res .= str_repeat(')', $p) . ';'; |
|
| 132 | 132 | $p = 0; |
| 133 | 133 | break; |
| 134 | 134 | default: |
| 135 | 135 | $res .= $ch; |
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | - $res = str_replace('nplurals','$total',$res); |
|
| 139 | - $res = str_replace('n','$n',$res); |
|
| 140 | - $res = str_replace('plural','$plural',$res); |
|
| 138 | + $res = str_replace('nplurals', '$total', $res); |
|
| 139 | + $res = str_replace('n', '$n', $res); |
|
| 140 | + $res = str_replace('plural', '$plural', $res); |
|
| 141 | 141 | return $res; |
| 142 | 142 | } |
| 143 | 143 | |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | { |
| 211 | 211 | // this should contains all strings separated by NULLs |
| 212 | 212 | $key = $single . chr(0) . $plural; |
| 213 | - if (! array_key_exists($key, $this->cache_translations)) { |
|
| 213 | + if (!array_key_exists($key, $this->cache_translations)) { |
|
| 214 | 214 | return ($number != 1) ? $plural : $single; |
| 215 | 215 | } |
| 216 | 216 | |
@@ -150,10 +150,11 @@ |
||
| 150 | 150 | */ |
| 151 | 151 | public static function extract_plural_forms_header_from_po_header($header) |
| 152 | 152 | { |
| 153 | - if (preg_match("/(^|\n)plural-forms: ([^\n]*)\n/i", $header, $regs)) |
|
| 154 | - $expr = $regs[2]; |
|
| 155 | - else |
|
| 156 | - $expr = "nplurals=2; plural=n == 1 ? 0 : 1;"; |
|
| 153 | + if (preg_match("/(^|\n)plural-forms: ([^\n]*)\n/i", $header, $regs)) { |
|
| 154 | + $expr = $regs[2]; |
|
| 155 | + } else { |
|
| 156 | + $expr = "nplurals=2; plural=n == 1 ? 0 : 1;"; |
|
| 157 | + } |
|
| 157 | 158 | return $expr; |
| 158 | 159 | } |
| 159 | 160 | |
@@ -35,7 +35,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | |
@@ -35,7 +35,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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)) { |
@@ -77,32 +77,45 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | |