@@ -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 | } |
@@ -164,9 +164,9 @@ discard block |
||
164 | 164 | * Returns passed in $locale, or environment variable $LANG if $locale == ''. |
165 | 165 | */ |
166 | 166 | function _get_default_locale($locale) { |
167 | - if ($locale == '') // emulate variable support |
|
167 | + if ($locale == '') // emulate variable support |
|
168 | 168 | return getenv('LANG'); |
169 | - else |
|
169 | + else |
|
170 | 170 | return $locale; |
171 | 171 | } |
172 | 172 | |
@@ -184,20 +184,20 @@ discard block |
||
184 | 184 | return _setlocale($category, $CURRENTLOCALE); |
185 | 185 | } else { |
186 | 186 | if (function_exists('setlocale')) { |
187 | - $ret = setlocale($category, $locale); |
|
188 | - if (($locale == '' and !$ret) or // failed setting it by env |
|
187 | + $ret = setlocale($category, $locale); |
|
188 | + if (($locale == '' and !$ret) or // failed setting it by env |
|
189 | 189 | ($locale != '' and $ret != $locale)) { // failed setting it |
190 | 190 | // Failed setting it according to environment. |
191 | 191 | $CURRENTLOCALE = _get_default_locale($locale); |
192 | 192 | $EMULATEGETTEXT = 1; |
193 | - } else { |
|
193 | + } else { |
|
194 | 194 | $CURRENTLOCALE = $ret; |
195 | 195 | $EMULATEGETTEXT = 0; |
196 | - } |
|
196 | + } |
|
197 | 197 | } else { |
198 | - // No function setlocale(), emulate it all. |
|
199 | - $CURRENTLOCALE = _get_default_locale($locale); |
|
200 | - $EMULATEGETTEXT = 1; |
|
198 | + // No function setlocale(), emulate it all. |
|
199 | + $CURRENTLOCALE = _get_default_locale($locale); |
|
200 | + $EMULATEGETTEXT = 1; |
|
201 | 201 | } |
202 | 202 | // Allow locale to be changed on the go for one translation domain. |
203 | 203 | global $text_domains, $default_domain; |
@@ -215,15 +215,15 @@ discard block |
||
215 | 215 | global $text_domains; |
216 | 216 | // ensure $path ends with a slash ('/' should work for both, but lets still play nice) |
217 | 217 | if (DIRECTORY_SEPARATOR == '\\') { |
218 | - if ($path[strlen($path)-1] != '\\' and $path[strlen($path)-1] != '/') |
|
218 | + if ($path[strlen($path)-1] != '\\' and $path[strlen($path)-1] != '/') |
|
219 | 219 | $path .= '\\'; |
220 | 220 | } else { |
221 | - if ($path[strlen($path)-1] != '/') |
|
221 | + if ($path[strlen($path)-1] != '/') |
|
222 | 222 | $path .= '/'; |
223 | 223 | } |
224 | 224 | if (!array_key_exists($domain, $text_domains)) { |
225 | - // Initialize an empty domain object. |
|
226 | - $text_domains[$domain] = new domain(); |
|
225 | + // Initialize an empty domain object. |
|
226 | + $text_domains[$domain] = new domain(); |
|
227 | 227 | } |
228 | 228 | $text_domains[$domain]->path = $path; |
229 | 229 | } |
@@ -291,8 +291,8 @@ discard block |
||
291 | 291 | return $l10n->gettext($msgid); |
292 | 292 | } |
293 | 293 | /** |
294 | - * Plural version of dcgettext. |
|
295 | - */ |
|
294 | + * Plural version of dcgettext. |
|
295 | + */ |
|
296 | 296 | function _dcngettext($domain, $singular, $plural, $number, $category) { |
297 | 297 | $l10n = _get_reader($domain, $category); |
298 | 298 | return $l10n->ngettext($singular, $plural, $number); |