@@ -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 | |
@@ -164,11 +180,13 @@ discard block |
||
| 164 | 180 | * Returns passed in $locale, or environment variable $LANG if $locale == ''. |
| 165 | 181 | */ |
| 166 | 182 | function _get_default_locale($locale) { |
| 167 | - if ($locale == '') // emulate variable support |
|
| 183 | + if ($locale == '') { |
|
| 184 | + // emulate variable support |
|
| 168 | 185 | return getenv('LANG'); |
| 169 | - else |
|
| 170 | - return $locale; |
|
| 171 | -} |
|
| 186 | + } else { |
|
| 187 | + return $locale; |
|
| 188 | + } |
|
| 189 | + } |
|
| 172 | 190 | |
| 173 | 191 | /** |
| 174 | 192 | * Sets a requested locale, if needed emulates it. |
@@ -176,12 +194,13 @@ discard block |
||
| 176 | 194 | function _setlocale($category, $locale) { |
| 177 | 195 | global $CURRENTLOCALE, $EMULATEGETTEXT; |
| 178 | 196 | if ($locale === 0) { // use === to differentiate between string "0" |
| 179 | - if ($CURRENTLOCALE != '') |
|
| 180 | - return $CURRENTLOCALE; |
|
| 181 | - else |
|
| 182 | - // obey LANG variable, maybe extend to support all of LC_* vars |
|
| 197 | + if ($CURRENTLOCALE != '') { |
|
| 198 | + return $CURRENTLOCALE; |
|
| 199 | + } else { |
|
| 200 | + // obey LANG variable, maybe extend to support all of LC_* vars |
|
| 183 | 201 | // even if we tried to read locale without setting it first |
| 184 | 202 | return _setlocale($category, $CURRENTLOCALE); |
| 203 | + } |
|
| 185 | 204 | } else { |
| 186 | 205 | if (function_exists('setlocale')) { |
| 187 | 206 | $ret = setlocale($category, $locale); |
@@ -215,11 +234,13 @@ discard block |
||
| 215 | 234 | global $text_domains; |
| 216 | 235 | // ensure $path ends with a slash ('/' should work for both, but lets still play nice) |
| 217 | 236 | if (DIRECTORY_SEPARATOR == '\\') { |
| 218 | - if ($path[strlen($path)-1] != '\\' and $path[strlen($path)-1] != '/') |
|
| 219 | - $path .= '\\'; |
|
| 237 | + if ($path[strlen($path)-1] != '\\' and $path[strlen($path)-1] != '/') { |
|
| 238 | + $path .= '\\'; |
|
| 239 | + } |
|
| 220 | 240 | } else { |
| 221 | - if ($path[strlen($path)-1] != '/') |
|
| 222 | - $path .= '/'; |
|
| 241 | + if ($path[strlen($path)-1] != '/') { |
|
| 242 | + $path .= '/'; |
|
| 243 | + } |
|
| 223 | 244 | } |
| 224 | 245 | if (!array_key_exists($domain, $text_domains)) { |
| 225 | 246 | // Initialize an empty domain object. |