|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Zend Framework |
|
4
|
|
|
* |
|
5
|
|
|
* LICENSE |
|
6
|
|
|
* |
|
7
|
|
|
* This source file is subject to the new BSD license that is bundled |
|
8
|
|
|
* with this package in the file LICENSE.txt. |
|
9
|
|
|
* It is also available through the world-wide-web at this URL: |
|
10
|
|
|
* http://framework.zend.com/license/new-bsd |
|
11
|
|
|
* If you did not receive a copy of the license and are unable to |
|
12
|
|
|
* obtain it through the world-wide-web, please send an email |
|
13
|
|
|
* to [email protected] so we can send you a copy immediately. |
|
14
|
|
|
* |
|
15
|
|
|
* @category Zend |
|
16
|
|
|
* @package Zend_Locale |
|
17
|
|
|
* @subpackage Data |
|
18
|
|
|
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) |
|
19
|
|
|
* @license http://framework.zend.com/license/new-bsd New BSD License |
|
20
|
|
|
* @version $Id: Data.php 24140 2011-06-14 02:11:19Z adamlundrigan $ |
|
21
|
|
|
*/ |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* include needed classes |
|
25
|
|
|
*/ |
|
26
|
|
|
require_once 'Zend/Locale.php'; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Locale data reader, handles the CLDR |
|
30
|
|
|
* |
|
31
|
|
|
* @category Zend |
|
32
|
|
|
* @package Zend_Locale |
|
33
|
|
|
* @subpackage Data |
|
34
|
|
|
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) |
|
35
|
|
|
* @license http://framework.zend.com/license/new-bsd New BSD License |
|
36
|
|
|
*/ |
|
37
|
|
|
class Zend_Locale_Data |
|
38
|
|
|
{ |
|
39
|
|
|
/** |
|
40
|
|
|
* Locale files |
|
41
|
|
|
* |
|
42
|
|
|
* @var ressource |
|
43
|
|
|
* @access private |
|
44
|
|
|
*/ |
|
45
|
|
|
private static $_ldml = array(); |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* List of values which are collected |
|
49
|
|
|
* |
|
50
|
|
|
* @var array |
|
51
|
|
|
* @access private |
|
52
|
|
|
*/ |
|
53
|
|
|
private static $_list = array(); |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Internal cache for ldml values |
|
57
|
|
|
* |
|
58
|
|
|
* @var Zend_Cache_Core |
|
59
|
|
|
* @access private |
|
60
|
|
|
*/ |
|
61
|
|
|
private static $_cache = null; |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Internal value to remember if cache supports tags |
|
65
|
|
|
* |
|
66
|
|
|
* @var boolean |
|
67
|
|
|
*/ |
|
68
|
|
|
private static $_cacheTags = false; |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* Internal option, cache disabled |
|
72
|
|
|
* |
|
73
|
|
|
* @var boolean |
|
74
|
|
|
* @access private |
|
75
|
|
|
*/ |
|
76
|
|
|
private static $_cacheDisabled = false; |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* Read the content from locale |
|
80
|
|
|
* |
|
81
|
|
|
* Can be called like: |
|
82
|
|
|
* <ldml> |
|
83
|
|
|
* <delimiter>test</delimiter> |
|
84
|
|
|
* <second type='myone'>content</second> |
|
85
|
|
|
* <second type='mysecond'>content2</second> |
|
86
|
|
|
* <third type='mythird' /> |
|
87
|
|
|
* </ldml> |
|
88
|
|
|
* |
|
89
|
|
|
* Case 1: _readFile('ar','/ldml/delimiter') -> returns [] = test |
|
90
|
|
|
* Case 1: _readFile('ar','/ldml/second[@type=myone]') -> returns [] = content |
|
91
|
|
|
* Case 2: _readFile('ar','/ldml/second','type') -> returns [myone] = content; [mysecond] = content2 |
|
92
|
|
|
* Case 3: _readFile('ar','/ldml/delimiter',,'right') -> returns [right] = test |
|
93
|
|
|
* Case 4: _readFile('ar','/ldml/third','type','myone') -> returns [myone] = mythird |
|
94
|
|
|
* |
|
95
|
|
|
* @param string $locale |
|
96
|
|
|
* @param string $path |
|
97
|
|
|
* @param string $attribute |
|
98
|
|
|
* @param string $value |
|
99
|
|
|
* @access private |
|
100
|
|
|
* @return array |
|
101
|
|
|
*/ |
|
102
|
|
|
private static function _readFile($locale, $path, $attribute, $value, $temp) |
|
103
|
|
|
{ |
|
104
|
|
|
// without attribute - read all values |
|
105
|
|
|
// with attribute - read only this value |
|
106
|
|
|
if (!empty(self::$_ldml[(string) $locale])) { |
|
107
|
|
|
|
|
108
|
|
|
$result = self::$_ldml[(string) $locale]->xpath($path); |
|
109
|
|
|
if (!empty($result)) { |
|
110
|
|
|
foreach ($result as &$found) { |
|
111
|
|
|
|
|
112
|
|
|
if (empty($value)) { |
|
113
|
|
|
|
|
114
|
|
|
if (empty($attribute)) { |
|
115
|
|
|
// Case 1 |
|
116
|
|
|
$temp[] = (string) $found; |
|
117
|
|
|
} else if (empty($temp[(string) $found[$attribute]])){ |
|
118
|
|
|
// Case 2 |
|
119
|
|
|
$temp[(string) $found[$attribute]] = (string) $found; |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
} else if (empty ($temp[$value])) { |
|
123
|
|
|
|
|
124
|
|
|
if (empty($attribute)) { |
|
125
|
|
|
// Case 3 |
|
126
|
|
|
$temp[$value] = (string) $found; |
|
127
|
|
|
} else { |
|
128
|
|
|
// Case 4 |
|
129
|
|
|
$temp[$value] = (string) $found[$attribute]; |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
} |
|
133
|
|
|
} |
|
134
|
|
|
} |
|
135
|
|
|
} |
|
136
|
|
|
return $temp; |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
/** |
|
140
|
|
|
* Find possible routing to other path or locale |
|
141
|
|
|
* |
|
142
|
|
|
* @param string $locale |
|
143
|
|
|
* @param string $path |
|
144
|
|
|
* @param string $attribute |
|
145
|
|
|
* @param string $value |
|
146
|
|
|
* @param array $temp |
|
147
|
|
|
* @throws Zend_Locale_Exception |
|
148
|
|
|
* @access private |
|
149
|
|
|
*/ |
|
150
|
|
|
private static function _findRoute($locale, $path, $attribute, $value, &$temp) |
|
151
|
|
|
{ |
|
152
|
|
|
// load locale file if not already in cache |
|
153
|
|
|
// needed for alias tag when referring to other locale |
|
154
|
|
|
if (empty(self::$_ldml[(string) $locale])) { |
|
155
|
|
|
$filename = dirname(__FILE__) . '/Data/' . $locale . '.xml'; |
|
156
|
|
|
if (!file_exists($filename)) { |
|
157
|
|
|
require_once 'Zend/Locale/Exception.php'; |
|
158
|
|
|
throw new Zend_Locale_Exception("Missing locale file '$filename' for '$locale' locale."); |
|
159
|
|
|
} |
|
160
|
|
|
|
|
161
|
|
|
self::$_ldml[(string) $locale] = simplexml_load_file($filename); |
|
162
|
|
|
} |
|
163
|
|
|
|
|
164
|
|
|
// search for 'alias' tag in the search path for redirection |
|
165
|
|
|
$search = ''; |
|
166
|
|
|
$tok = strtok($path, '/'); |
|
167
|
|
|
|
|
168
|
|
|
// parse the complete path |
|
169
|
|
|
if (!empty(self::$_ldml[(string) $locale])) { |
|
170
|
|
|
while ($tok !== false) { |
|
171
|
|
|
$search .= '/' . $tok; |
|
172
|
|
|
if (strpos($search, '[@') !== false) { |
|
173
|
|
|
while (strrpos($search, '[@') > strrpos($search, ']')) { |
|
174
|
|
|
$tok = strtok('/'); |
|
175
|
|
|
if (empty($tok)) { |
|
176
|
|
|
$search .= '/'; |
|
177
|
|
|
} |
|
178
|
|
|
$search = $search . '/' . $tok; |
|
179
|
|
|
} |
|
180
|
|
|
} |
|
181
|
|
|
$result = self::$_ldml[(string) $locale]->xpath($search . '/alias'); |
|
182
|
|
|
|
|
183
|
|
|
// alias found |
|
184
|
|
|
if (!empty($result)) { |
|
185
|
|
|
|
|
186
|
|
|
$source = $result[0]['source']; |
|
187
|
|
|
$newpath = $result[0]['path']; |
|
188
|
|
|
|
|
189
|
|
|
// new path - path //ldml is to ignore |
|
190
|
|
|
if ($newpath != '//ldml') { |
|
191
|
|
|
// other path - parse to make real path |
|
192
|
|
|
|
|
193
|
|
|
while (substr($newpath,0,3) == '../') { |
|
194
|
|
|
$newpath = substr($newpath, 3); |
|
195
|
|
|
$search = substr($search, 0, strrpos($search, '/')); |
|
196
|
|
|
} |
|
197
|
|
|
|
|
198
|
|
|
// truncate ../ to realpath otherwise problems with alias |
|
199
|
|
|
$path = $search . '/' . $newpath; |
|
200
|
|
|
while (($tok = strtok('/'))!== false) { |
|
201
|
|
|
$path = $path . '/' . $tok; |
|
202
|
|
|
} |
|
203
|
|
|
} |
|
204
|
|
|
|
|
205
|
|
|
// reroute to other locale |
|
206
|
|
|
if ($source != 'locale') { |
|
207
|
|
|
$locale = $source; |
|
208
|
|
|
} |
|
209
|
|
|
|
|
210
|
|
|
$temp = self::_getFile($locale, $path, $attribute, $value, $temp); |
|
211
|
|
|
return false; |
|
212
|
|
|
} |
|
213
|
|
|
|
|
214
|
|
|
$tok = strtok('/'); |
|
215
|
|
|
} |
|
216
|
|
|
} |
|
217
|
|
|
return true; |
|
218
|
|
|
} |
|
219
|
|
|
|
|
220
|
|
|
/** |
|
221
|
|
|
* Read the right LDML file |
|
222
|
|
|
* |
|
223
|
|
|
* @param string $locale |
|
224
|
|
|
* @param string $path |
|
225
|
|
|
* @param string $attribute |
|
226
|
|
|
* @param string $value |
|
227
|
|
|
* @access private |
|
228
|
|
|
*/ |
|
229
|
|
|
private static function _getFile($locale, $path, $attribute = false, $value = false, $temp = array()) |
|
230
|
|
|
{ |
|
231
|
|
|
$result = self::_findRoute($locale, $path, $attribute, $value, $temp); |
|
232
|
|
|
if ($result) { |
|
233
|
|
|
$temp = self::_readFile($locale, $path, $attribute, $value, $temp); |
|
234
|
|
|
} |
|
235
|
|
|
|
|
236
|
|
|
// parse required locales reversive |
|
237
|
|
|
// example: when given zh_Hans_CN |
|
238
|
|
|
// 1. -> zh_Hans_CN |
|
239
|
|
|
// 2. -> zh_Hans |
|
240
|
|
|
// 3. -> zh |
|
241
|
|
|
// 4. -> root |
|
242
|
|
|
if (($locale != 'root') && ($result)) { |
|
243
|
|
|
$locale = substr($locale, 0, -strlen(strrchr($locale, '_'))); |
|
244
|
|
|
if (!empty($locale)) { |
|
245
|
|
|
$temp = self::_getFile($locale, $path, $attribute, $value, $temp); |
|
246
|
|
|
} else { |
|
247
|
|
|
$temp = self::_getFile('root', $path, $attribute, $value, $temp); |
|
248
|
|
|
} |
|
249
|
|
|
} |
|
250
|
|
|
return $temp; |
|
251
|
|
|
} |
|
252
|
|
|
|
|
253
|
|
|
/** |
|
254
|
|
|
* Find the details for supplemental calendar datas |
|
255
|
|
|
* |
|
256
|
|
|
* @param string $locale Locale for Detaildata |
|
257
|
|
|
* @param array $list List to search |
|
258
|
|
|
* @return string Key for Detaildata |
|
259
|
|
|
*/ |
|
260
|
|
|
private static function _calendarDetail($locale, $list) |
|
261
|
|
|
{ |
|
262
|
|
|
$ret = "001"; |
|
263
|
|
|
foreach ($list as $key => $value) { |
|
264
|
|
|
if (strpos($locale, '_') !== false) { |
|
265
|
|
|
$locale = substr($locale, strpos($locale, '_') + 1); |
|
266
|
|
|
} |
|
267
|
|
|
if (strpos($key, $locale) !== false) { |
|
268
|
|
|
$ret = $key; |
|
269
|
|
|
break; |
|
270
|
|
|
} |
|
271
|
|
|
} |
|
272
|
|
|
return $ret; |
|
273
|
|
|
} |
|
274
|
|
|
|
|
275
|
|
|
/** |
|
276
|
|
|
* Internal function for checking the locale |
|
277
|
|
|
* |
|
278
|
|
|
* @param string|Zend_Locale $locale Locale to check |
|
279
|
|
|
* @return string |
|
280
|
|
|
*/ |
|
281
|
|
|
private static function _checkLocale($locale) |
|
282
|
|
|
{ |
|
283
|
|
|
if (empty($locale)) { |
|
284
|
|
|
$locale = new Zend_Locale(); |
|
285
|
|
|
} |
|
286
|
|
|
|
|
287
|
|
|
if (!(Zend_Locale::isLocale((string) $locale, null, false))) { |
|
288
|
|
|
require_once 'Zend/Locale/Exception.php'; |
|
289
|
|
|
throw new Zend_Locale_Exception("Locale (" . (string) $locale . ") is a unknown locale"); |
|
290
|
|
|
} |
|
291
|
|
|
|
|
292
|
|
|
return (string) $locale; |
|
293
|
|
|
} |
|
294
|
|
|
|
|
295
|
|
|
/** |
|
296
|
|
|
* Read the LDML file, get a array of multipath defined value |
|
297
|
|
|
* |
|
298
|
|
|
* @param string $locale |
|
299
|
|
|
* @param string $path |
|
300
|
|
|
* @param string $value |
|
301
|
|
|
* @return array |
|
302
|
|
|
* @access public |
|
303
|
|
|
*/ |
|
304
|
|
|
public static function getList($locale, $path, $value = false) |
|
305
|
|
|
{ |
|
306
|
|
|
$locale = self::_checkLocale($locale); |
|
307
|
|
|
|
|
308
|
|
|
if (!isset(self::$_cache) && !self::$_cacheDisabled) { |
|
309
|
|
|
require_once 'Zend/Cache.php'; |
|
310
|
|
|
self::$_cache = Zend_Cache::factory( |
|
311
|
|
|
'Core', |
|
312
|
|
|
'File', |
|
313
|
|
|
array('automatic_serialization' => true), |
|
314
|
|
|
array()); |
|
315
|
|
|
} |
|
316
|
|
|
|
|
317
|
|
|
$val = $value; |
|
318
|
|
|
if (is_array($value)) { |
|
319
|
|
|
$val = implode('_' , $value); |
|
320
|
|
|
} |
|
321
|
|
|
|
|
322
|
|
|
$val = urlencode($val); |
|
323
|
|
|
$id = strtr('Zend_LocaleL_' . $locale . '_' . $path . '_' . $val, array('-' => '_', '%' => '_', '+' => '_')); |
|
324
|
|
|
if (!self::$_cacheDisabled && ($result = self::$_cache->load($id))) { |
|
325
|
|
|
return unserialize($result); |
|
326
|
|
|
} |
|
327
|
|
|
|
|
328
|
|
|
$temp = array(); |
|
329
|
|
|
switch(strtolower($path)) { |
|
330
|
|
|
case 'language': |
|
331
|
|
|
$temp = self::_getFile($locale, '/ldml/localeDisplayNames/languages/language', 'type'); |
|
332
|
|
|
break; |
|
333
|
|
|
|
|
334
|
|
|
case 'script': |
|
335
|
|
|
$temp = self::_getFile($locale, '/ldml/localeDisplayNames/scripts/script', 'type'); |
|
336
|
|
|
break; |
|
337
|
|
|
|
|
338
|
|
|
case 'territory': |
|
339
|
|
|
$temp = self::_getFile($locale, '/ldml/localeDisplayNames/territories/territory', 'type'); |
|
340
|
|
|
if ($value === 1) { |
|
341
|
|
|
foreach($temp as $key => $value) { |
|
342
|
|
|
if ((is_numeric($key) === false) and ($key != 'QO') and ($key != 'QU')) { |
|
343
|
|
|
unset($temp[$key]); |
|
344
|
|
|
} |
|
345
|
|
|
} |
|
346
|
|
|
} else if ($value === 2) { |
|
347
|
|
|
foreach($temp as $key => $value) { |
|
348
|
|
|
if (is_numeric($key) or ($key == 'QO') or ($key == 'QU')) { |
|
349
|
|
|
unset($temp[$key]); |
|
350
|
|
|
} |
|
351
|
|
|
} |
|
352
|
|
|
} |
|
353
|
|
|
break; |
|
354
|
|
|
|
|
355
|
|
|
case 'variant': |
|
356
|
|
|
$temp = self::_getFile($locale, '/ldml/localeDisplayNames/variants/variant', 'type'); |
|
357
|
|
|
break; |
|
358
|
|
|
|
|
359
|
|
|
case 'key': |
|
360
|
|
|
$temp = self::_getFile($locale, '/ldml/localeDisplayNames/keys/key', 'type'); |
|
361
|
|
|
break; |
|
362
|
|
|
|
|
363
|
|
|
case 'type': |
|
364
|
|
|
if (empty($type)) { |
|
365
|
|
|
$temp = self::_getFile($locale, '/ldml/localeDisplayNames/types/type', 'type'); |
|
366
|
|
|
} else { |
|
367
|
|
|
if (($value == 'calendar') or |
|
368
|
|
|
($value == 'collation') or |
|
369
|
|
|
($value == 'currency')) { |
|
370
|
|
|
$temp = self::_getFile($locale, '/ldml/localeDisplayNames/types/type[@key=\'' . $value . '\']', 'type'); |
|
371
|
|
|
} else { |
|
372
|
|
|
$temp = self::_getFile($locale, '/ldml/localeDisplayNames/types/type[@type=\'' . $value . '\']', 'type'); |
|
373
|
|
|
} |
|
374
|
|
|
} |
|
375
|
|
|
break; |
|
376
|
|
|
|
|
377
|
|
|
case 'layout': |
|
378
|
|
|
$temp = self::_getFile($locale, '/ldml/layout/orientation', 'lines', 'lines'); |
|
379
|
|
|
$temp += self::_getFile($locale, '/ldml/layout/orientation', 'characters', 'characters'); |
|
380
|
|
|
$temp += self::_getFile($locale, '/ldml/layout/inList', '', 'inList'); |
|
381
|
|
|
$temp += self::_getFile($locale, '/ldml/layout/inText[@type=\'currency\']', '', 'currency'); |
|
382
|
|
|
$temp += self::_getFile($locale, '/ldml/layout/inText[@type=\'dayWidth\']', '', 'dayWidth'); |
|
383
|
|
|
$temp += self::_getFile($locale, '/ldml/layout/inText[@type=\'fields\']', '', 'fields'); |
|
384
|
|
|
$temp += self::_getFile($locale, '/ldml/layout/inText[@type=\'keys\']', '', 'keys'); |
|
385
|
|
|
$temp += self::_getFile($locale, '/ldml/layout/inText[@type=\'languages\']', '', 'languages'); |
|
386
|
|
|
$temp += self::_getFile($locale, '/ldml/layout/inText[@type=\'long\']', '', 'long'); |
|
387
|
|
|
$temp += self::_getFile($locale, '/ldml/layout/inText[@type=\'measurementSystemNames\']', '', 'measurementSystemNames'); |
|
388
|
|
|
$temp += self::_getFile($locale, '/ldml/layout/inText[@type=\'monthWidth\']', '', 'monthWidth'); |
|
389
|
|
|
$temp += self::_getFile($locale, '/ldml/layout/inText[@type=\'quarterWidth\']', '', 'quarterWidth'); |
|
390
|
|
|
$temp += self::_getFile($locale, '/ldml/layout/inText[@type=\'scripts\']', '', 'scripts'); |
|
391
|
|
|
$temp += self::_getFile($locale, '/ldml/layout/inText[@type=\'territories\']', '', 'territories'); |
|
392
|
|
|
$temp += self::_getFile($locale, '/ldml/layout/inText[@type=\'types\']', '', 'types'); |
|
393
|
|
|
$temp += self::_getFile($locale, '/ldml/layout/inText[@type=\'variants\']', '', 'variants'); |
|
394
|
|
|
break; |
|
395
|
|
|
|
|
396
|
|
|
case 'characters': |
|
397
|
|
|
$temp = self::_getFile($locale, '/ldml/characters/exemplarCharacters', '', 'characters'); |
|
398
|
|
|
$temp += self::_getFile($locale, '/ldml/characters/exemplarCharacters[@type=\'auxiliary\']', '', 'auxiliary'); |
|
399
|
|
|
$temp += self::_getFile($locale, '/ldml/characters/exemplarCharacters[@type=\'currencySymbol\']', '', 'currencySymbol'); |
|
400
|
|
|
break; |
|
401
|
|
|
|
|
402
|
|
|
case 'delimiters': |
|
403
|
|
|
$temp = self::_getFile($locale, '/ldml/delimiters/quotationStart', '', 'quoteStart'); |
|
404
|
|
|
$temp += self::_getFile($locale, '/ldml/delimiters/quotationEnd', '', 'quoteEnd'); |
|
405
|
|
|
$temp += self::_getFile($locale, '/ldml/delimiters/alternateQuotationStart', '', 'quoteStartAlt'); |
|
406
|
|
|
$temp += self::_getFile($locale, '/ldml/delimiters/alternateQuotationEnd', '', 'quoteEndAlt'); |
|
407
|
|
|
break; |
|
408
|
|
|
|
|
409
|
|
|
case 'measurement': |
|
410
|
|
|
$temp = self::_getFile('supplementalData', '/supplementalData/measurementData/measurementSystem[@type=\'metric\']', 'territories', 'metric'); |
|
411
|
|
|
$temp += self::_getFile('supplementalData', '/supplementalData/measurementData/measurementSystem[@type=\'US\']', 'territories', 'US'); |
|
412
|
|
|
$temp += self::_getFile('supplementalData', '/supplementalData/measurementData/paperSize[@type=\'A4\']', 'territories', 'A4'); |
|
413
|
|
|
$temp += self::_getFile('supplementalData', '/supplementalData/measurementData/paperSize[@type=\'US-Letter\']', 'territories', 'US-Letter'); |
|
414
|
|
|
break; |
|
415
|
|
|
|
|
416
|
|
|
case 'months': |
|
417
|
|
|
if (empty($value)) { |
|
418
|
|
|
$value = "gregorian"; |
|
419
|
|
|
} |
|
420
|
|
|
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/default', 'choice', 'context'); |
|
421
|
|
|
$temp += self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'format\']/default', 'choice', 'default'); |
|
422
|
|
|
$temp['format']['abbreviated'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'format\']/monthWidth[@type=\'abbreviated\']/month', 'type'); |
|
423
|
|
|
$temp['format']['narrow'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'format\']/monthWidth[@type=\'narrow\']/month', 'type'); |
|
424
|
|
|
$temp['format']['wide'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'format\']/monthWidth[@type=\'wide\']/month', 'type'); |
|
425
|
|
|
$temp['stand-alone']['abbreviated'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'stand-alone\']/monthWidth[@type=\'abbreviated\']/month', 'type'); |
|
426
|
|
|
$temp['stand-alone']['narrow'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'stand-alone\']/monthWidth[@type=\'narrow\']/month', 'type'); |
|
427
|
|
|
$temp['stand-alone']['wide'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'stand-alone\']/monthWidth[@type=\'wide\']/month', 'type'); |
|
428
|
|
|
break; |
|
429
|
|
|
|
|
430
|
|
|
case 'month': |
|
431
|
|
|
if (empty($value)) { |
|
432
|
|
|
$value = array("gregorian", "format", "wide"); |
|
433
|
|
|
} |
|
434
|
|
|
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/months/monthContext[@type=\'' . $value[1] . '\']/monthWidth[@type=\'' . $value[2] . '\']/month', 'type'); |
|
435
|
|
|
break; |
|
436
|
|
|
|
|
437
|
|
|
case 'days': |
|
438
|
|
|
if (empty($value)) { |
|
439
|
|
|
$value = "gregorian"; |
|
440
|
|
|
} |
|
441
|
|
|
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/default', 'choice', 'context'); |
|
442
|
|
|
$temp += self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'format\']/default', 'choice', 'default'); |
|
443
|
|
|
$temp['format']['abbreviated'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'format\']/dayWidth[@type=\'abbreviated\']/day', 'type'); |
|
444
|
|
|
$temp['format']['narrow'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'format\']/dayWidth[@type=\'narrow\']/day', 'type'); |
|
445
|
|
|
$temp['format']['wide'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'format\']/dayWidth[@type=\'wide\']/day', 'type'); |
|
446
|
|
|
$temp['stand-alone']['abbreviated'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'stand-alone\']/dayWidth[@type=\'abbreviated\']/day', 'type'); |
|
447
|
|
|
$temp['stand-alone']['narrow'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'stand-alone\']/dayWidth[@type=\'narrow\']/day', 'type'); |
|
448
|
|
|
$temp['stand-alone']['wide'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'stand-alone\']/dayWidth[@type=\'wide\']/day', 'type'); |
|
449
|
|
|
break; |
|
450
|
|
|
|
|
451
|
|
|
case 'day': |
|
452
|
|
|
if (empty($value)) { |
|
453
|
|
|
$value = array("gregorian", "format", "wide"); |
|
454
|
|
|
} |
|
455
|
|
|
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/days/dayContext[@type=\'' . $value[1] . '\']/dayWidth[@type=\'' . $value[2] . '\']/day', 'type'); |
|
456
|
|
|
break; |
|
457
|
|
|
|
|
458
|
|
|
case 'week': |
|
459
|
|
|
$minDays = self::_calendarDetail($locale, self::_getFile('supplementalData', '/supplementalData/weekData/minDays', 'territories')); |
|
460
|
|
|
$firstDay = self::_calendarDetail($locale, self::_getFile('supplementalData', '/supplementalData/weekData/firstDay', 'territories')); |
|
461
|
|
|
$weekStart = self::_calendarDetail($locale, self::_getFile('supplementalData', '/supplementalData/weekData/weekendStart', 'territories')); |
|
462
|
|
|
$weekEnd = self::_calendarDetail($locale, self::_getFile('supplementalData', '/supplementalData/weekData/weekendEnd', 'territories')); |
|
463
|
|
|
|
|
464
|
|
|
$temp = self::_getFile('supplementalData', "/supplementalData/weekData/minDays[@territories='" . $minDays . "']", 'count', 'minDays'); |
|
465
|
|
|
$temp += self::_getFile('supplementalData', "/supplementalData/weekData/firstDay[@territories='" . $firstDay . "']", 'day', 'firstDay'); |
|
466
|
|
|
$temp += self::_getFile('supplementalData', "/supplementalData/weekData/weekendStart[@territories='" . $weekStart . "']", 'day', 'weekendStart'); |
|
467
|
|
|
$temp += self::_getFile('supplementalData', "/supplementalData/weekData/weekendEnd[@territories='" . $weekEnd . "']", 'day', 'weekendEnd'); |
|
468
|
|
|
break; |
|
469
|
|
|
|
|
470
|
|
|
case 'quarters': |
|
471
|
|
|
if (empty($value)) { |
|
472
|
|
|
$value = "gregorian"; |
|
473
|
|
|
} |
|
474
|
|
|
$temp['format']['abbreviated'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/quarters/quarterContext[@type=\'format\']/quarterWidth[@type=\'abbreviated\']/quarter', 'type'); |
|
475
|
|
|
$temp['format']['narrow'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/quarters/quarterContext[@type=\'format\']/quarterWidth[@type=\'narrow\']/quarter', 'type'); |
|
476
|
|
|
$temp['format']['wide'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/quarters/quarterContext[@type=\'format\']/quarterWidth[@type=\'wide\']/quarter', 'type'); |
|
477
|
|
|
$temp['stand-alone']['abbreviated'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/quarters/quarterContext[@type=\'stand-alone\']/quarterWidth[@type=\'abbreviated\']/quarter', 'type'); |
|
478
|
|
|
$temp['stand-alone']['narrow'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/quarters/quarterContext[@type=\'stand-alone\']/quarterWidth[@type=\'narrow\']/quarter', 'type'); |
|
479
|
|
|
$temp['stand-alone']['wide'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/quarters/quarterContext[@type=\'stand-alone\']/quarterWidth[@type=\'wide\']/quarter', 'type'); |
|
480
|
|
|
break; |
|
481
|
|
|
|
|
482
|
|
|
case 'quarter': |
|
483
|
|
|
if (empty($value)) { |
|
484
|
|
|
$value = array("gregorian", "format", "wide"); |
|
485
|
|
|
} |
|
486
|
|
|
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/quarters/quarterContext[@type=\'' . $value[1] . '\']/quarterWidth[@type=\'' . $value[2] . '\']/quarter', 'type'); |
|
487
|
|
|
break; |
|
488
|
|
|
|
|
489
|
|
|
case 'eras': |
|
490
|
|
|
if (empty($value)) { |
|
491
|
|
|
$value = "gregorian"; |
|
492
|
|
|
} |
|
493
|
|
|
$temp['names'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/eras/eraNames/era', 'type'); |
|
494
|
|
|
$temp['abbreviated'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/eras/eraAbbr/era', 'type'); |
|
495
|
|
|
$temp['narrow'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/eras/eraNarrow/era', 'type'); |
|
496
|
|
|
break; |
|
497
|
|
|
|
|
498
|
|
|
case 'era': |
|
499
|
|
|
if (empty($value)) { |
|
500
|
|
|
$value = array("gregorian", "Abbr"); |
|
501
|
|
|
} |
|
502
|
|
|
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/eras/era' . $value[1] . '/era', 'type'); |
|
503
|
|
|
break; |
|
504
|
|
|
|
|
505
|
|
|
case 'date': |
|
506
|
|
|
if (empty($value)) { |
|
507
|
|
|
$value = "gregorian"; |
|
508
|
|
|
} |
|
509
|
|
|
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateFormats/dateFormatLength[@type=\'full\']/dateFormat/pattern', '', 'full'); |
|
510
|
|
|
$temp += self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateFormats/dateFormatLength[@type=\'long\']/dateFormat/pattern', '', 'long'); |
|
511
|
|
|
$temp += self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateFormats/dateFormatLength[@type=\'medium\']/dateFormat/pattern', '', 'medium'); |
|
512
|
|
|
$temp += self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateFormats/dateFormatLength[@type=\'short\']/dateFormat/pattern', '', 'short'); |
|
513
|
|
|
break; |
|
514
|
|
|
|
|
515
|
|
|
case 'time': |
|
516
|
|
|
if (empty($value)) { |
|
517
|
|
|
$value = "gregorian"; |
|
518
|
|
|
} |
|
519
|
|
|
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/timeFormats/timeFormatLength[@type=\'full\']/timeFormat/pattern', '', 'full'); |
|
520
|
|
|
$temp += self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/timeFormats/timeFormatLength[@type=\'long\']/timeFormat/pattern', '', 'long'); |
|
521
|
|
|
$temp += self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/timeFormats/timeFormatLength[@type=\'medium\']/timeFormat/pattern', '', 'medium'); |
|
522
|
|
|
$temp += self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/timeFormats/timeFormatLength[@type=\'short\']/timeFormat/pattern', '', 'short'); |
|
523
|
|
|
break; |
|
524
|
|
|
|
|
525
|
|
|
case 'datetime': |
|
526
|
|
|
if (empty($value)) { |
|
527
|
|
|
$value = "gregorian"; |
|
528
|
|
|
} |
|
529
|
|
|
|
|
530
|
|
|
$timefull = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/timeFormats/timeFormatLength[@type=\'full\']/timeFormat/pattern', '', 'full'); |
|
531
|
|
|
$timelong = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/timeFormats/timeFormatLength[@type=\'long\']/timeFormat/pattern', '', 'long'); |
|
532
|
|
|
$timemedi = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/timeFormats/timeFormatLength[@type=\'medium\']/timeFormat/pattern', '', 'medi'); |
|
533
|
|
|
$timeshor = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/timeFormats/timeFormatLength[@type=\'short\']/timeFormat/pattern', '', 'shor'); |
|
534
|
|
|
|
|
535
|
|
|
$datefull = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateFormats/dateFormatLength[@type=\'full\']/dateFormat/pattern', '', 'full'); |
|
536
|
|
|
$datelong = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateFormats/dateFormatLength[@type=\'long\']/dateFormat/pattern', '', 'long'); |
|
537
|
|
|
$datemedi = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateFormats/dateFormatLength[@type=\'medium\']/dateFormat/pattern', '', 'medi'); |
|
538
|
|
|
$dateshor = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateFormats/dateFormatLength[@type=\'short\']/dateFormat/pattern', '', 'shor'); |
|
539
|
|
|
|
|
540
|
|
|
$full = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateTimeFormats/dateTimeFormatLength[@type=\'full\']/dateTimeFormat/pattern', '', 'full'); |
|
541
|
|
|
$long = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateTimeFormats/dateTimeFormatLength[@type=\'long\']/dateTimeFormat/pattern', '', 'long'); |
|
542
|
|
|
$medi = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateTimeFormats/dateTimeFormatLength[@type=\'medium\']/dateTimeFormat/pattern', '', 'medi'); |
|
543
|
|
|
$shor = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateTimeFormats/dateTimeFormatLength[@type=\'short\']/dateTimeFormat/pattern', '', 'shor'); |
|
544
|
|
|
|
|
545
|
|
|
$temp['full'] = str_replace(array('{0}', '{1}'), array($timefull['full'], $datefull['full']), $full['full']); |
|
546
|
|
|
$temp['long'] = str_replace(array('{0}', '{1}'), array($timelong['long'], $datelong['long']), $long['long']); |
|
547
|
|
|
$temp['medium'] = str_replace(array('{0}', '{1}'), array($timemedi['medi'], $datemedi['medi']), $medi['medi']); |
|
548
|
|
|
$temp['short'] = str_replace(array('{0}', '{1}'), array($timeshor['shor'], $dateshor['shor']), $shor['shor']); |
|
549
|
|
|
break; |
|
550
|
|
|
|
|
551
|
|
|
case 'dateitem': |
|
552
|
|
|
if (empty($value)) { |
|
553
|
|
|
$value = "gregorian"; |
|
554
|
|
|
} |
|
555
|
|
|
$_temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateTimeFormats/availableFormats/dateFormatItem', 'id'); |
|
556
|
|
|
foreach($_temp as $key => $found) { |
|
557
|
|
|
$temp += self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateTimeFormats/availableFormats/dateFormatItem[@id=\'' . $key . '\']', '', $key); |
|
558
|
|
|
} |
|
559
|
|
|
break; |
|
560
|
|
|
|
|
561
|
|
|
case 'dateinterval': |
|
562
|
|
|
if (empty($value)) { |
|
563
|
|
|
$value = "gregorian"; |
|
564
|
|
|
} |
|
565
|
|
|
$_temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateTimeFormats/intervalFormats/intervalFormatItem', 'id'); |
|
566
|
|
|
foreach($_temp as $key => $found) { |
|
567
|
|
|
$temp[$key] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateTimeFormats/intervalFormats/intervalFormatItem[@id=\'' . $key . '\']/greatestDifference', 'id'); |
|
568
|
|
|
} |
|
569
|
|
|
break; |
|
570
|
|
|
|
|
571
|
|
|
case 'field': |
|
572
|
|
|
if (empty($value)) { |
|
573
|
|
|
$value = "gregorian"; |
|
574
|
|
|
} |
|
575
|
|
|
$temp2 = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/fields/field', 'type'); |
|
576
|
|
|
foreach ($temp2 as $key => $keyvalue) { |
|
577
|
|
|
$temp += self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/fields/field[@type=\'' . $key . '\']/displayName', '', $key); |
|
578
|
|
|
} |
|
579
|
|
|
break; |
|
580
|
|
|
|
|
581
|
|
|
case 'relative': |
|
582
|
|
|
if (empty($value)) { |
|
583
|
|
|
$value = "gregorian"; |
|
584
|
|
|
} |
|
585
|
|
|
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/fields/field/relative', 'type'); |
|
586
|
|
|
break; |
|
587
|
|
|
|
|
588
|
|
|
case 'symbols': |
|
589
|
|
|
$temp = self::_getFile($locale, '/ldml/numbers/symbols/decimal', '', 'decimal'); |
|
590
|
|
|
$temp += self::_getFile($locale, '/ldml/numbers/symbols/group', '', 'group'); |
|
591
|
|
|
$temp += self::_getFile($locale, '/ldml/numbers/symbols/list', '', 'list'); |
|
592
|
|
|
$temp += self::_getFile($locale, '/ldml/numbers/symbols/percentSign', '', 'percent'); |
|
593
|
|
|
$temp += self::_getFile($locale, '/ldml/numbers/symbols/nativeZeroDigit', '', 'zero'); |
|
594
|
|
|
$temp += self::_getFile($locale, '/ldml/numbers/symbols/patternDigit', '', 'pattern'); |
|
595
|
|
|
$temp += self::_getFile($locale, '/ldml/numbers/symbols/plusSign', '', 'plus'); |
|
596
|
|
|
$temp += self::_getFile($locale, '/ldml/numbers/symbols/minusSign', '', 'minus'); |
|
597
|
|
|
$temp += self::_getFile($locale, '/ldml/numbers/symbols/exponential', '', 'exponent'); |
|
598
|
|
|
$temp += self::_getFile($locale, '/ldml/numbers/symbols/perMille', '', 'mille'); |
|
599
|
|
|
$temp += self::_getFile($locale, '/ldml/numbers/symbols/infinity', '', 'infinity'); |
|
600
|
|
|
$temp += self::_getFile($locale, '/ldml/numbers/symbols/nan', '', 'nan'); |
|
601
|
|
|
break; |
|
602
|
|
|
|
|
603
|
|
|
case 'nametocurrency': |
|
604
|
|
|
$_temp = self::_getFile($locale, '/ldml/numbers/currencies/currency', 'type'); |
|
605
|
|
|
foreach ($_temp as $key => $found) { |
|
606
|
|
|
$temp += self::_getFile($locale, '/ldml/numbers/currencies/currency[@type=\'' . $key . '\']/displayName', '', $key); |
|
607
|
|
|
} |
|
608
|
|
|
break; |
|
609
|
|
|
|
|
610
|
|
|
case 'currencytoname': |
|
611
|
|
|
$_temp = self::_getFile($locale, '/ldml/numbers/currencies/currency', 'type'); |
|
612
|
|
|
foreach ($_temp as $key => $keyvalue) { |
|
613
|
|
|
$val = self::_getFile($locale, '/ldml/numbers/currencies/currency[@type=\'' . $key . '\']/displayName', '', $key); |
|
614
|
|
|
if (!isset($val[$key])) { |
|
615
|
|
|
continue; |
|
616
|
|
|
} |
|
617
|
|
|
if (!isset($temp[$val[$key]])) { |
|
618
|
|
|
$temp[$val[$key]] = $key; |
|
619
|
|
|
} else { |
|
620
|
|
|
$temp[$val[$key]] .= " " . $key; |
|
621
|
|
|
} |
|
622
|
|
|
} |
|
623
|
|
|
break; |
|
624
|
|
|
|
|
625
|
|
|
case 'currencysymbol': |
|
626
|
|
|
$_temp = self::_getFile($locale, '/ldml/numbers/currencies/currency', 'type'); |
|
627
|
|
|
foreach ($_temp as $key => $found) { |
|
628
|
|
|
$temp += self::_getFile($locale, '/ldml/numbers/currencies/currency[@type=\'' . $key . '\']/symbol', '', $key); |
|
629
|
|
|
} |
|
630
|
|
|
break; |
|
631
|
|
|
|
|
632
|
|
|
case 'question': |
|
633
|
|
|
$temp = self::_getFile($locale, '/ldml/posix/messages/yesstr', '', 'yes'); |
|
634
|
|
|
$temp += self::_getFile($locale, '/ldml/posix/messages/nostr', '', 'no'); |
|
635
|
|
|
break; |
|
636
|
|
|
|
|
637
|
|
|
case 'currencyfraction': |
|
638
|
|
|
$_temp = self::_getFile('supplementalData', '/supplementalData/currencyData/fractions/info', 'iso4217'); |
|
639
|
|
|
foreach ($_temp as $key => $found) { |
|
640
|
|
|
$temp += self::_getFile('supplementalData', '/supplementalData/currencyData/fractions/info[@iso4217=\'' . $key . '\']', 'digits', $key); |
|
641
|
|
|
} |
|
642
|
|
|
break; |
|
643
|
|
|
|
|
644
|
|
|
case 'currencyrounding': |
|
645
|
|
|
$_temp = self::_getFile('supplementalData', '/supplementalData/currencyData/fractions/info', 'iso4217'); |
|
646
|
|
|
foreach ($_temp as $key => $found) { |
|
647
|
|
|
$temp += self::_getFile('supplementalData', '/supplementalData/currencyData/fractions/info[@iso4217=\'' . $key . '\']', 'rounding', $key); |
|
648
|
|
|
} |
|
649
|
|
|
break; |
|
650
|
|
|
|
|
651
|
|
|
case 'currencytoregion': |
|
652
|
|
|
$_temp = self::_getFile('supplementalData', '/supplementalData/currencyData/region', 'iso3166'); |
|
653
|
|
|
foreach ($_temp as $key => $keyvalue) { |
|
654
|
|
|
$temp += self::_getFile('supplementalData', '/supplementalData/currencyData/region[@iso3166=\'' . $key . '\']/currency', 'iso4217', $key); |
|
655
|
|
|
} |
|
656
|
|
|
break; |
|
657
|
|
|
|
|
658
|
|
|
case 'regiontocurrency': |
|
659
|
|
|
$_temp = self::_getFile('supplementalData', '/supplementalData/currencyData/region', 'iso3166'); |
|
660
|
|
|
foreach ($_temp as $key => $keyvalue) { |
|
661
|
|
|
$val = self::_getFile('supplementalData', '/supplementalData/currencyData/region[@iso3166=\'' . $key . '\']/currency', 'iso4217', $key); |
|
662
|
|
|
if (!isset($val[$key])) { |
|
663
|
|
|
continue; |
|
664
|
|
|
} |
|
665
|
|
|
if (!isset($temp[$val[$key]])) { |
|
666
|
|
|
$temp[$val[$key]] = $key; |
|
667
|
|
|
} else { |
|
668
|
|
|
$temp[$val[$key]] .= " " . $key; |
|
669
|
|
|
} |
|
670
|
|
|
} |
|
671
|
|
|
break; |
|
672
|
|
|
|
|
673
|
|
|
case 'regiontoterritory': |
|
674
|
|
|
$_temp = self::_getFile('supplementalData', '/supplementalData/territoryContainment/group', 'type'); |
|
675
|
|
|
foreach ($_temp as $key => $found) { |
|
676
|
|
|
$temp += self::_getFile('supplementalData', '/supplementalData/territoryContainment/group[@type=\'' . $key . '\']', 'contains', $key); |
|
677
|
|
|
} |
|
678
|
|
|
break; |
|
679
|
|
|
|
|
680
|
|
|
case 'territorytoregion': |
|
681
|
|
|
$_temp2 = self::_getFile('supplementalData', '/supplementalData/territoryContainment/group', 'type'); |
|
682
|
|
|
$_temp = array(); |
|
683
|
|
|
foreach ($_temp2 as $key => $found) { |
|
684
|
|
|
$_temp += self::_getFile('supplementalData', '/supplementalData/territoryContainment/group[@type=\'' . $key . '\']', 'contains', $key); |
|
685
|
|
|
} |
|
686
|
|
|
foreach($_temp as $key => $found) { |
|
687
|
|
|
$_temp3 = explode(" ", $found); |
|
688
|
|
|
foreach($_temp3 as $found3) { |
|
689
|
|
|
if (!isset($temp[$found3])) { |
|
690
|
|
|
$temp[$found3] = (string) $key; |
|
691
|
|
|
} else { |
|
692
|
|
|
$temp[$found3] .= " " . $key; |
|
693
|
|
|
} |
|
694
|
|
|
} |
|
695
|
|
|
} |
|
696
|
|
|
break; |
|
697
|
|
|
|
|
698
|
|
|
case 'scripttolanguage': |
|
699
|
|
|
$_temp = self::_getFile('supplementalData', '/supplementalData/languageData/language', 'type'); |
|
700
|
|
|
foreach ($_temp as $key => $found) { |
|
701
|
|
|
$temp += self::_getFile('supplementalData', '/supplementalData/languageData/language[@type=\'' . $key . '\']', 'scripts', $key); |
|
702
|
|
|
if (empty($temp[$key])) { |
|
703
|
|
|
unset($temp[$key]); |
|
704
|
|
|
} |
|
705
|
|
|
} |
|
706
|
|
|
break; |
|
707
|
|
|
|
|
708
|
|
|
case 'languagetoscript': |
|
709
|
|
|
$_temp2 = self::_getFile('supplementalData', '/supplementalData/languageData/language', 'type'); |
|
710
|
|
|
$_temp = array(); |
|
711
|
|
|
foreach ($_temp2 as $key => $found) { |
|
712
|
|
|
$_temp += self::_getFile('supplementalData', '/supplementalData/languageData/language[@type=\'' . $key . '\']', 'scripts', $key); |
|
713
|
|
|
} |
|
714
|
|
|
foreach($_temp as $key => $found) { |
|
715
|
|
|
$_temp3 = explode(" ", $found); |
|
716
|
|
|
foreach($_temp3 as $found3) { |
|
717
|
|
|
if (empty($found3)) { |
|
718
|
|
|
continue; |
|
719
|
|
|
} |
|
720
|
|
|
if (!isset($temp[$found3])) { |
|
721
|
|
|
$temp[$found3] = (string) $key; |
|
722
|
|
|
} else { |
|
723
|
|
|
$temp[$found3] .= " " . $key; |
|
724
|
|
|
} |
|
725
|
|
|
} |
|
726
|
|
|
} |
|
727
|
|
|
break; |
|
728
|
|
|
|
|
729
|
|
|
case 'territorytolanguage': |
|
730
|
|
|
$_temp = self::_getFile('supplementalData', '/supplementalData/languageData/language', 'type'); |
|
731
|
|
|
foreach ($_temp as $key => $found) { |
|
732
|
|
|
$temp += self::_getFile('supplementalData', '/supplementalData/languageData/language[@type=\'' . $key . '\']', 'territories', $key); |
|
733
|
|
|
if (empty($temp[$key])) { |
|
734
|
|
|
unset($temp[$key]); |
|
735
|
|
|
} |
|
736
|
|
|
} |
|
737
|
|
|
break; |
|
738
|
|
|
|
|
739
|
|
|
case 'languagetoterritory': |
|
740
|
|
|
$_temp2 = self::_getFile('supplementalData', '/supplementalData/languageData/language', 'type'); |
|
741
|
|
|
$_temp = array(); |
|
742
|
|
|
foreach ($_temp2 as $key => $found) { |
|
743
|
|
|
$_temp += self::_getFile('supplementalData', '/supplementalData/languageData/language[@type=\'' . $key . '\']', 'territories', $key); |
|
744
|
|
|
} |
|
745
|
|
|
foreach($_temp as $key => $found) { |
|
746
|
|
|
$_temp3 = explode(" ", $found); |
|
747
|
|
|
foreach($_temp3 as $found3) { |
|
748
|
|
|
if (empty($found3)) { |
|
749
|
|
|
continue; |
|
750
|
|
|
} |
|
751
|
|
|
if (!isset($temp[$found3])) { |
|
752
|
|
|
$temp[$found3] = (string) $key; |
|
753
|
|
|
} else { |
|
754
|
|
|
$temp[$found3] .= " " . $key; |
|
755
|
|
|
} |
|
756
|
|
|
} |
|
757
|
|
|
} |
|
758
|
|
|
break; |
|
759
|
|
|
|
|
760
|
|
|
case 'timezonetowindows': |
|
761
|
|
|
$_temp = self::_getFile('supplementalData', '/supplementalData/timezoneData/mapTimezones[@type=\'windows\']/mapZone', 'other'); |
|
762
|
|
|
foreach ($_temp as $key => $found) { |
|
763
|
|
|
$temp += self::_getFile('supplementalData', '/supplementalData/timezoneData/mapTimezones[@type=\'windows\']/mapZone[@other=\'' . $key . '\']', 'type', $key); |
|
764
|
|
|
} |
|
765
|
|
|
break; |
|
766
|
|
|
|
|
767
|
|
|
case 'windowstotimezone': |
|
768
|
|
|
$_temp = self::_getFile('supplementalData', '/supplementalData/timezoneData/mapTimezones[@type=\'windows\']/mapZone', 'type'); |
|
769
|
|
|
foreach ($_temp as $key => $found) { |
|
770
|
|
|
$temp += self::_getFile('supplementalData', '/supplementalData/timezoneData/mapTimezones[@type=\'windows\']/mapZone[@type=\'' .$key . '\']', 'other', $key); |
|
771
|
|
|
} |
|
772
|
|
|
break; |
|
773
|
|
|
|
|
774
|
|
|
case 'territorytotimezone': |
|
775
|
|
|
$_temp = self::_getFile('supplementalData', '/supplementalData/timezoneData/zoneFormatting/zoneItem', 'type'); |
|
776
|
|
|
foreach ($_temp as $key => $found) { |
|
777
|
|
|
$temp += self::_getFile('supplementalData', '/supplementalData/timezoneData/zoneFormatting/zoneItem[@type=\'' . $key . '\']', 'territory', $key); |
|
778
|
|
|
} |
|
779
|
|
|
break; |
|
780
|
|
|
|
|
781
|
|
|
case 'timezonetoterritory': |
|
782
|
|
|
$_temp = self::_getFile('supplementalData', '/supplementalData/timezoneData/zoneFormatting/zoneItem', 'territory'); |
|
783
|
|
|
foreach ($_temp as $key => $found) { |
|
784
|
|
|
$temp += self::_getFile('supplementalData', '/supplementalData/timezoneData/zoneFormatting/zoneItem[@territory=\'' . $key . '\']', 'type', $key); |
|
785
|
|
|
} |
|
786
|
|
|
break; |
|
787
|
|
|
|
|
788
|
|
|
case 'citytotimezone': |
|
789
|
|
|
$_temp = self::_getFile($locale, '/ldml/dates/timeZoneNames/zone', 'type'); |
|
790
|
|
|
foreach($_temp as $key => $found) { |
|
791
|
|
|
$temp += self::_getFile($locale, '/ldml/dates/timeZoneNames/zone[@type=\'' . $key . '\']/exemplarCity', '', $key); |
|
792
|
|
|
} |
|
793
|
|
|
break; |
|
794
|
|
|
|
|
795
|
|
|
case 'timezonetocity': |
|
796
|
|
|
$_temp = self::_getFile($locale, '/ldml/dates/timeZoneNames/zone', 'type'); |
|
797
|
|
|
$temp = array(); |
|
798
|
|
|
foreach($_temp as $key => $found) { |
|
799
|
|
|
$temp += self::_getFile($locale, '/ldml/dates/timeZoneNames/zone[@type=\'' . $key . '\']/exemplarCity', '', $key); |
|
800
|
|
|
if (!empty($temp[$key])) { |
|
801
|
|
|
$temp[$temp[$key]] = $key; |
|
802
|
|
|
} |
|
803
|
|
|
unset($temp[$key]); |
|
804
|
|
|
} |
|
805
|
|
|
break; |
|
806
|
|
|
|
|
807
|
|
|
case 'phonetoterritory': |
|
808
|
|
|
$_temp = self::_getFile('telephoneCodeData', '/supplementalData/telephoneCodeData/codesByTerritory', 'territory'); |
|
809
|
|
|
foreach ($_temp as $key => $keyvalue) { |
|
810
|
|
|
$temp += self::_getFile('telephoneCodeData', '/supplementalData/telephoneCodeData/codesByTerritory[@territory=\'' . $key . '\']/telephoneCountryCode', 'code', $key); |
|
811
|
|
|
} |
|
812
|
|
|
break; |
|
813
|
|
|
|
|
814
|
|
|
case 'territorytophone': |
|
815
|
|
|
$_temp = self::_getFile('telephoneCodeData', '/supplementalData/telephoneCodeData/codesByTerritory', 'territory'); |
|
816
|
|
|
foreach ($_temp as $key => $keyvalue) { |
|
817
|
|
|
$val = self::_getFile('telephoneCodeData', '/supplementalData/telephoneCodeData/codesByTerritory[@territory=\'' . $key . '\']/telephoneCountryCode', 'code', $key); |
|
818
|
|
|
if (!isset($val[$key])) { |
|
819
|
|
|
continue; |
|
820
|
|
|
} |
|
821
|
|
|
if (!isset($temp[$val[$key]])) { |
|
822
|
|
|
$temp[$val[$key]] = $key; |
|
823
|
|
|
} else { |
|
824
|
|
|
$temp[$val[$key]] .= " " . $key; |
|
825
|
|
|
} |
|
826
|
|
|
} |
|
827
|
|
|
break; |
|
828
|
|
|
|
|
829
|
|
|
case 'numerictoterritory': |
|
830
|
|
|
$_temp = self::_getFile('supplementalData', '/supplementalData/codeMappings/territoryCodes', 'type'); |
|
831
|
|
|
foreach ($_temp as $key => $keyvalue) { |
|
832
|
|
|
$temp += self::_getFile('supplementalData', '/supplementalData/codeMappings/territoryCodes[@type=\'' . $key . '\']', 'numeric', $key); |
|
833
|
|
|
} |
|
834
|
|
|
break; |
|
835
|
|
|
|
|
836
|
|
|
case 'territorytonumeric': |
|
837
|
|
|
$_temp = self::_getFile('supplementalData', '/supplementalData/codeMappings/territoryCodes', 'numeric'); |
|
838
|
|
|
foreach ($_temp as $key => $keyvalue) { |
|
839
|
|
|
$temp += self::_getFile('supplementalData', '/supplementalData/codeMappings/territoryCodes[@numeric=\'' . $key . '\']', 'type', $key); |
|
840
|
|
|
} |
|
841
|
|
|
break; |
|
842
|
|
|
|
|
843
|
|
|
case 'alpha3toterritory': |
|
844
|
|
|
$_temp = self::_getFile('supplementalData', '/supplementalData/codeMappings/territoryCodes', 'type'); |
|
845
|
|
|
foreach ($_temp as $key => $keyvalue) { |
|
846
|
|
|
$temp += self::_getFile('supplementalData', '/supplementalData/codeMappings/territoryCodes[@type=\'' . $key . '\']', 'alpha3', $key); |
|
847
|
|
|
} |
|
848
|
|
|
break; |
|
849
|
|
|
|
|
850
|
|
|
case 'territorytoalpha3': |
|
851
|
|
|
$_temp = self::_getFile('supplementalData', '/supplementalData/codeMappings/territoryCodes', 'alpha3'); |
|
852
|
|
|
foreach ($_temp as $key => $keyvalue) { |
|
853
|
|
|
$temp += self::_getFile('supplementalData', '/supplementalData/codeMappings/territoryCodes[@alpha3=\'' . $key . '\']', 'type', $key); |
|
854
|
|
|
} |
|
855
|
|
|
break; |
|
856
|
|
|
|
|
857
|
|
|
case 'postaltoterritory': |
|
858
|
|
|
$_temp = self::_getFile('postalCodeData', '/supplementalData/postalCodeData/postCodeRegex', 'territoryId'); |
|
859
|
|
|
foreach ($_temp as $key => $keyvalue) { |
|
860
|
|
|
$temp += self::_getFile('postalCodeData', '/supplementalData/postalCodeData/postCodeRegex[@territoryId=\'' . $key . '\']', 'territoryId'); |
|
861
|
|
|
} |
|
862
|
|
|
break; |
|
863
|
|
|
|
|
864
|
|
|
case 'numberingsystem': |
|
865
|
|
|
$_temp = self::_getFile('numberingSystems', '/supplementalData/numberingSystems/numberingSystem', 'id'); |
|
866
|
|
|
foreach ($_temp as $key => $keyvalue) { |
|
867
|
|
|
$temp += self::_getFile('numberingSystems', '/supplementalData/numberingSystems/numberingSystem[@id=\'' . $key . '\']', 'digits', $key); |
|
868
|
|
|
if (empty($temp[$key])) { |
|
869
|
|
|
unset($temp[$key]); |
|
870
|
|
|
} |
|
871
|
|
|
} |
|
872
|
|
|
break; |
|
873
|
|
|
|
|
874
|
|
|
case 'chartofallback': |
|
875
|
|
|
$_temp = self::_getFile('characters', '/supplementalData/characters/character-fallback/character', 'value'); |
|
876
|
|
|
foreach ($_temp as $key => $keyvalue) { |
|
877
|
|
|
$temp2 = self::_getFile('characters', '/supplementalData/characters/character-fallback/character[@value=\'' . $key . '\']/substitute', '', $key); |
|
878
|
|
|
$temp[current($temp2)] = $key; |
|
879
|
|
|
} |
|
880
|
|
|
break; |
|
881
|
|
|
|
|
882
|
|
|
case 'fallbacktochar': |
|
883
|
|
|
$_temp = self::_getFile('characters', '/supplementalData/characters/character-fallback/character', 'value'); |
|
884
|
|
|
foreach ($_temp as $key => $keyvalue) { |
|
885
|
|
|
$temp += self::_getFile('characters', '/supplementalData/characters/character-fallback/character[@value=\'' . $key . '\']/substitute', '', $key); |
|
886
|
|
|
} |
|
887
|
|
|
break; |
|
888
|
|
|
|
|
889
|
|
|
case 'localeupgrade': |
|
890
|
|
|
$_temp = self::_getFile('likelySubtags', '/supplementalData/likelySubtags/likelySubtag', 'from'); |
|
891
|
|
|
foreach ($_temp as $key => $keyvalue) { |
|
892
|
|
|
$temp += self::_getFile('likelySubtags', '/supplementalData/likelySubtags/likelySubtag[@from=\'' . $key . '\']', 'to', $key); |
|
893
|
|
|
} |
|
894
|
|
|
break; |
|
895
|
|
|
|
|
896
|
|
|
case 'unit': |
|
897
|
|
|
$_temp = self::_getFile($locale, '/ldml/units/unit', 'type'); |
|
898
|
|
|
foreach($_temp as $key => $keyvalue) { |
|
899
|
|
|
$_temp2 = self::_getFile($locale, '/ldml/units/unit[@type=\'' . $key . '\']/unitPattern', 'count'); |
|
900
|
|
|
$temp[$key] = $_temp2; |
|
901
|
|
|
} |
|
902
|
|
|
break; |
|
903
|
|
|
|
|
904
|
|
|
default : |
|
905
|
|
|
require_once 'Zend/Locale/Exception.php'; |
|
906
|
|
|
throw new Zend_Locale_Exception("Unknown list ($path) for parsing locale data."); |
|
907
|
|
|
break; |
|
908
|
|
|
} |
|
909
|
|
|
|
|
910
|
|
|
if (isset(self::$_cache)) { |
|
911
|
|
|
if (self::$_cacheTags) { |
|
912
|
|
|
self::$_cache->save( serialize($temp), $id, array('Zend_Locale')); |
|
913
|
|
|
} else { |
|
914
|
|
|
self::$_cache->save( serialize($temp), $id); |
|
915
|
|
|
} |
|
916
|
|
|
} |
|
917
|
|
|
|
|
918
|
|
|
return $temp; |
|
919
|
|
|
} |
|
920
|
|
|
|
|
921
|
|
|
/** |
|
922
|
|
|
* Read the LDML file, get a single path defined value |
|
923
|
|
|
* |
|
924
|
|
|
* @param string $locale |
|
925
|
|
|
* @param string $path |
|
926
|
|
|
* @param string $value |
|
927
|
|
|
* @return string |
|
928
|
|
|
* @access public |
|
929
|
|
|
*/ |
|
930
|
|
|
public static function getContent($locale, $path, $value = false) |
|
931
|
|
|
{ |
|
932
|
|
|
$locale = self::_checkLocale($locale); |
|
933
|
|
|
|
|
934
|
|
|
if (!isset(self::$_cache) && !self::$_cacheDisabled) { |
|
935
|
|
|
require_once 'Zend/Cache.php'; |
|
936
|
|
|
self::$_cache = Zend_Cache::factory( |
|
937
|
|
|
'Core', |
|
938
|
|
|
'File', |
|
939
|
|
|
array('automatic_serialization' => true), |
|
940
|
|
|
array()); |
|
941
|
|
|
} |
|
942
|
|
|
|
|
943
|
|
|
$val = $value; |
|
944
|
|
|
if (is_array($value)) { |
|
945
|
|
|
$val = implode('_' , $value); |
|
946
|
|
|
} |
|
947
|
|
|
$val = urlencode($val); |
|
948
|
|
|
$id = strtr('Zend_LocaleC_' . $locale . '_' . $path . '_' . $val, array('-' => '_', '%' => '_', '+' => '_')); |
|
949
|
|
|
if (!self::$_cacheDisabled && ($result = self::$_cache->load($id))) { |
|
950
|
|
|
return unserialize($result); |
|
951
|
|
|
} |
|
952
|
|
|
|
|
953
|
|
|
switch(strtolower($path)) { |
|
954
|
|
|
case 'language': |
|
955
|
|
|
$temp = self::_getFile($locale, '/ldml/localeDisplayNames/languages/language[@type=\'' . $value . '\']', 'type'); |
|
956
|
|
|
break; |
|
957
|
|
|
|
|
958
|
|
|
case 'script': |
|
959
|
|
|
$temp = self::_getFile($locale, '/ldml/localeDisplayNames/scripts/script[@type=\'' . $value . '\']', 'type'); |
|
960
|
|
|
break; |
|
961
|
|
|
|
|
962
|
|
|
case 'country': |
|
963
|
|
|
case 'territory': |
|
964
|
|
|
$temp = self::_getFile($locale, '/ldml/localeDisplayNames/territories/territory[@type=\'' . $value . '\']', 'type'); |
|
965
|
|
|
break; |
|
966
|
|
|
|
|
967
|
|
|
case 'variant': |
|
968
|
|
|
$temp = self::_getFile($locale, '/ldml/localeDisplayNames/variants/variant[@type=\'' . $value . '\']', 'type'); |
|
969
|
|
|
break; |
|
970
|
|
|
|
|
971
|
|
|
case 'key': |
|
972
|
|
|
$temp = self::_getFile($locale, '/ldml/localeDisplayNames/keys/key[@type=\'' . $value . '\']', 'type'); |
|
973
|
|
|
break; |
|
974
|
|
|
|
|
975
|
|
|
case 'defaultcalendar': |
|
976
|
|
|
$temp = self::_getFile($locale, '/ldml/dates/calendars/default', 'choice', 'default'); |
|
977
|
|
|
break; |
|
978
|
|
|
|
|
979
|
|
|
case 'monthcontext': |
|
980
|
|
|
if (empty ($value)) { |
|
981
|
|
|
$value = "gregorian"; |
|
982
|
|
|
} |
|
983
|
|
|
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/default', 'choice', 'context'); |
|
984
|
|
|
break; |
|
985
|
|
|
|
|
986
|
|
|
case 'defaultmonth': |
|
987
|
|
|
if (empty ($value)) { |
|
988
|
|
|
$value = "gregorian"; |
|
989
|
|
|
} |
|
990
|
|
|
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'format\']/default', 'choice', 'default'); |
|
991
|
|
|
break; |
|
992
|
|
|
|
|
993
|
|
|
case 'month': |
|
994
|
|
|
if (!is_array($value)) { |
|
995
|
|
|
$temp = $value; |
|
996
|
|
|
$value = array("gregorian", "format", "wide", $temp); |
|
997
|
|
|
} |
|
998
|
|
|
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/months/monthContext[@type=\'' . $value[1] . '\']/monthWidth[@type=\'' . $value[2] . '\']/month[@type=\'' . $value[3] . '\']', 'type'); |
|
999
|
|
|
break; |
|
1000
|
|
|
|
|
1001
|
|
|
case 'daycontext': |
|
1002
|
|
|
if (empty($value)) { |
|
1003
|
|
|
$value = "gregorian"; |
|
1004
|
|
|
} |
|
1005
|
|
|
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/default', 'choice', 'context'); |
|
1006
|
|
|
break; |
|
1007
|
|
|
|
|
1008
|
|
|
case 'defaultday': |
|
1009
|
|
|
if (empty($value)) { |
|
1010
|
|
|
$value = "gregorian"; |
|
1011
|
|
|
} |
|
1012
|
|
|
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'format\']/default', 'choice', 'default'); |
|
1013
|
|
|
break; |
|
1014
|
|
|
|
|
1015
|
|
|
case 'day': |
|
1016
|
|
|
if (!is_array($value)) { |
|
1017
|
|
|
$temp = $value; |
|
1018
|
|
|
$value = array("gregorian", "format", "wide", $temp); |
|
1019
|
|
|
} |
|
1020
|
|
|
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/days/dayContext[@type=\'' . $value[1] . '\']/dayWidth[@type=\'' . $value[2] . '\']/day[@type=\'' . $value[3] . '\']', 'type'); |
|
1021
|
|
|
break; |
|
1022
|
|
|
|
|
1023
|
|
|
case 'quarter': |
|
1024
|
|
|
if (!is_array($value)) { |
|
1025
|
|
|
$temp = $value; |
|
1026
|
|
|
$value = array("gregorian", "format", "wide", $temp); |
|
1027
|
|
|
} |
|
1028
|
|
|
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/quarters/quarterContext[@type=\'' . $value[1] . '\']/quarterWidth[@type=\'' . $value[2] . '\']/quarter[@type=\'' . $value[3] . '\']', 'type'); |
|
1029
|
|
|
break; |
|
1030
|
|
|
|
|
1031
|
|
|
case 'am': |
|
1032
|
|
|
if (empty($value)) { |
|
1033
|
|
|
$value = "gregorian"; |
|
1034
|
|
|
} |
|
1035
|
|
|
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/am', '', 'am'); |
|
1036
|
|
|
break; |
|
1037
|
|
|
|
|
1038
|
|
|
case 'pm': |
|
1039
|
|
|
if (empty($value)) { |
|
1040
|
|
|
$value = "gregorian"; |
|
1041
|
|
|
} |
|
1042
|
|
|
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/pm', '', 'pm'); |
|
1043
|
|
|
break; |
|
1044
|
|
|
|
|
1045
|
|
|
case 'era': |
|
1046
|
|
|
if (!is_array($value)) { |
|
1047
|
|
|
$temp = $value; |
|
1048
|
|
|
$value = array("gregorian", "Abbr", $temp); |
|
1049
|
|
|
} |
|
1050
|
|
|
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/eras/era' . $value[1] . '/era[@type=\'' . $value[2] . '\']', 'type'); |
|
1051
|
|
|
break; |
|
1052
|
|
|
|
|
1053
|
|
|
case 'defaultdate': |
|
1054
|
|
|
if (empty($value)) { |
|
1055
|
|
|
$value = "gregorian"; |
|
1056
|
|
|
} |
|
1057
|
|
|
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateFormats/default', 'choice', 'default'); |
|
1058
|
|
|
break; |
|
1059
|
|
|
|
|
1060
|
|
|
case 'date': |
|
1061
|
|
|
if (empty($value)) { |
|
1062
|
|
|
$value = array("gregorian", "medium"); |
|
1063
|
|
|
} |
|
1064
|
|
|
if (!is_array($value)) { |
|
1065
|
|
|
$temp = $value; |
|
1066
|
|
|
$value = array("gregorian", $temp); |
|
1067
|
|
|
} |
|
1068
|
|
|
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/dateFormats/dateFormatLength[@type=\'' . $value[1] . '\']/dateFormat/pattern', '', 'pattern'); |
|
1069
|
|
|
break; |
|
1070
|
|
|
|
|
1071
|
|
|
case 'defaulttime': |
|
1072
|
|
|
if (empty($value)) { |
|
1073
|
|
|
$value = "gregorian"; |
|
1074
|
|
|
} |
|
1075
|
|
|
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/timeFormats/default', 'choice', 'default'); |
|
1076
|
|
|
break; |
|
1077
|
|
|
|
|
1078
|
|
|
case 'time': |
|
1079
|
|
|
if (empty($value)) { |
|
1080
|
|
|
$value = array("gregorian", "medium"); |
|
1081
|
|
|
} |
|
1082
|
|
|
if (!is_array($value)) { |
|
1083
|
|
|
$temp = $value; |
|
1084
|
|
|
$value = array("gregorian", $temp); |
|
1085
|
|
|
} |
|
1086
|
|
|
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/timeFormats/timeFormatLength[@type=\'' . $value[1] . '\']/timeFormat/pattern', '', 'pattern'); |
|
1087
|
|
|
break; |
|
1088
|
|
|
|
|
1089
|
|
|
case 'datetime': |
|
1090
|
|
|
if (empty($value)) { |
|
1091
|
|
|
$value = array("gregorian", "medium"); |
|
1092
|
|
|
} |
|
1093
|
|
|
if (!is_array($value)) { |
|
1094
|
|
|
$temp = $value; |
|
1095
|
|
|
$value = array("gregorian", $temp); |
|
1096
|
|
|
} |
|
1097
|
|
|
|
|
1098
|
|
|
$date = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/dateFormats/dateFormatLength[@type=\'' . $value[1] . '\']/dateFormat/pattern', '', 'pattern'); |
|
1099
|
|
|
$time = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/timeFormats/timeFormatLength[@type=\'' . $value[1] . '\']/timeFormat/pattern', '', 'pattern'); |
|
1100
|
|
|
$datetime = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/dateTimeFormats/dateTimeFormatLength[@type=\'' . $value[1] . '\']/dateTimeFormat/pattern', '', 'pattern'); |
|
1101
|
|
|
$temp = str_replace(array('{0}', '{1}'), array(current($time), current($date)), current($datetime)); |
|
1102
|
|
|
break; |
|
1103
|
|
|
|
|
1104
|
|
|
case 'dateitem': |
|
1105
|
|
|
if (empty($value)) { |
|
1106
|
|
|
$value = array("gregorian", "yyMMdd"); |
|
1107
|
|
|
} |
|
1108
|
|
|
if (!is_array($value)) { |
|
1109
|
|
|
$temp = $value; |
|
1110
|
|
|
$value = array("gregorian", $temp); |
|
1111
|
|
|
} |
|
1112
|
|
|
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/dateTimeFormats/availableFormats/dateFormatItem[@id=\'' . $value[1] . '\']', ''); |
|
1113
|
|
|
break; |
|
1114
|
|
|
|
|
1115
|
|
|
case 'dateinterval': |
|
1116
|
|
|
if (empty($value)) { |
|
1117
|
|
|
$value = array("gregorian", "yMd", "y"); |
|
1118
|
|
|
} |
|
1119
|
|
|
if (!is_array($value)) { |
|
1120
|
|
|
$temp = $value; |
|
1121
|
|
|
$value = array("gregorian", $temp, $temp[0]); |
|
1122
|
|
|
} |
|
1123
|
|
|
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/dateTimeFormats/intervalFormats/intervalFormatItem[@id=\'' . $value[1] . '\']/greatestDifference[@id=\'' . $value[2] . '\']', ''); |
|
1124
|
|
|
break; |
|
1125
|
|
|
|
|
1126
|
|
|
case 'field': |
|
1127
|
|
|
if (!is_array($value)) { |
|
1128
|
|
|
$temp = $value; |
|
1129
|
|
|
$value = array("gregorian", $temp); |
|
1130
|
|
|
} |
|
1131
|
|
|
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/fields/field[@type=\'' . $value[1] . '\']/displayName', '', $value[1]); |
|
1132
|
|
|
break; |
|
1133
|
|
|
|
|
1134
|
|
|
case 'relative': |
|
1135
|
|
|
if (!is_array($value)) { |
|
1136
|
|
|
$temp = $value; |
|
1137
|
|
|
$value = array("gregorian", $temp); |
|
1138
|
|
|
} |
|
1139
|
|
|
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/fields/field/relative[@type=\'' . $value[1] . '\']', '', $value[1]); |
|
1140
|
|
|
break; |
|
1141
|
|
|
|
|
1142
|
|
|
case 'defaultnumberingsystem': |
|
1143
|
|
|
$temp = self::_getFile($locale, '/ldml/numbers/defaultNumberingSystem', '', 'default'); |
|
1144
|
|
|
break; |
|
1145
|
|
|
|
|
1146
|
|
|
case 'decimalnumber': |
|
1147
|
|
|
$temp = self::_getFile($locale, '/ldml/numbers/decimalFormats/decimalFormatLength/decimalFormat/pattern', '', 'default'); |
|
1148
|
|
|
break; |
|
1149
|
|
|
|
|
1150
|
|
|
case 'scientificnumber': |
|
1151
|
|
|
$temp = self::_getFile($locale, '/ldml/numbers/scientificFormats/scientificFormatLength/scientificFormat/pattern', '', 'default'); |
|
1152
|
|
|
break; |
|
1153
|
|
|
|
|
1154
|
|
|
case 'percentnumber': |
|
1155
|
|
|
$temp = self::_getFile($locale, '/ldml/numbers/percentFormats/percentFormatLength/percentFormat/pattern', '', 'default'); |
|
1156
|
|
|
break; |
|
1157
|
|
|
|
|
1158
|
|
|
case 'currencynumber': |
|
1159
|
|
|
$temp = self::_getFile($locale, '/ldml/numbers/currencyFormats/currencyFormatLength/currencyFormat/pattern', '', 'default'); |
|
1160
|
|
|
break; |
|
1161
|
|
|
|
|
1162
|
|
|
case 'nametocurrency': |
|
1163
|
|
|
$temp = self::_getFile($locale, '/ldml/numbers/currencies/currency[@type=\'' . $value . '\']/displayName', '', $value); |
|
1164
|
|
|
break; |
|
1165
|
|
|
|
|
1166
|
|
|
case 'currencytoname': |
|
1167
|
|
|
$temp = self::_getFile($locale, '/ldml/numbers/currencies/currency[@type=\'' . $value . '\']/displayName', '', $value); |
|
1168
|
|
|
$_temp = self::_getFile($locale, '/ldml/numbers/currencies/currency', 'type'); |
|
1169
|
|
|
$temp = array(); |
|
1170
|
|
|
foreach ($_temp as $key => $keyvalue) { |
|
1171
|
|
|
$val = self::_getFile($locale, '/ldml/numbers/currencies/currency[@type=\'' . $key . '\']/displayName', '', $key); |
|
1172
|
|
|
if (!isset($val[$key]) or ($val[$key] != $value)) { |
|
1173
|
|
|
continue; |
|
1174
|
|
|
} |
|
1175
|
|
|
if (!isset($temp[$val[$key]])) { |
|
1176
|
|
|
$temp[$val[$key]] = $key; |
|
1177
|
|
|
} else { |
|
1178
|
|
|
$temp[$val[$key]] .= " " . $key; |
|
1179
|
|
|
} |
|
1180
|
|
|
} |
|
1181
|
|
|
break; |
|
1182
|
|
|
|
|
1183
|
|
|
case 'currencysymbol': |
|
1184
|
|
|
$temp = self::_getFile($locale, '/ldml/numbers/currencies/currency[@type=\'' . $value . '\']/symbol', '', $value); |
|
1185
|
|
|
break; |
|
1186
|
|
|
|
|
1187
|
|
|
case 'question': |
|
1188
|
|
|
$temp = self::_getFile($locale, '/ldml/posix/messages/' . $value . 'str', '', $value); |
|
1189
|
|
|
break; |
|
1190
|
|
|
|
|
1191
|
|
|
case 'currencyfraction': |
|
1192
|
|
|
if (empty($value)) { |
|
1193
|
|
|
$value = "DEFAULT"; |
|
1194
|
|
|
} |
|
1195
|
|
|
$temp = self::_getFile('supplementalData', '/supplementalData/currencyData/fractions/info[@iso4217=\'' . $value . '\']', 'digits', 'digits'); |
|
1196
|
|
|
break; |
|
1197
|
|
|
|
|
1198
|
|
|
case 'currencyrounding': |
|
1199
|
|
|
if (empty($value)) { |
|
1200
|
|
|
$value = "DEFAULT"; |
|
1201
|
|
|
} |
|
1202
|
|
|
$temp = self::_getFile('supplementalData', '/supplementalData/currencyData/fractions/info[@iso4217=\'' . $value . '\']', 'rounding', 'rounding'); |
|
1203
|
|
|
break; |
|
1204
|
|
|
|
|
1205
|
|
|
case 'currencytoregion': |
|
1206
|
|
|
$temp = self::_getFile('supplementalData', '/supplementalData/currencyData/region[@iso3166=\'' . $value . '\']/currency', 'iso4217', $value); |
|
1207
|
|
|
break; |
|
1208
|
|
|
|
|
1209
|
|
|
case 'regiontocurrency': |
|
1210
|
|
|
$_temp = self::_getFile('supplementalData', '/supplementalData/currencyData/region', 'iso3166'); |
|
1211
|
|
|
$temp = array(); |
|
1212
|
|
|
foreach ($_temp as $key => $keyvalue) { |
|
1213
|
|
|
$val = self::_getFile('supplementalData', '/supplementalData/currencyData/region[@iso3166=\'' . $key . '\']/currency', 'iso4217', $key); |
|
1214
|
|
|
if (!isset($val[$key]) or ($val[$key] != $value)) { |
|
1215
|
|
|
continue; |
|
1216
|
|
|
} |
|
1217
|
|
|
if (!isset($temp[$val[$key]])) { |
|
1218
|
|
|
$temp[$val[$key]] = $key; |
|
1219
|
|
|
} else { |
|
1220
|
|
|
$temp[$val[$key]] .= " " . $key; |
|
1221
|
|
|
} |
|
1222
|
|
|
} |
|
1223
|
|
|
break; |
|
1224
|
|
|
|
|
1225
|
|
|
case 'regiontoterritory': |
|
1226
|
|
|
$temp = self::_getFile('supplementalData', '/supplementalData/territoryContainment/group[@type=\'' . $value . '\']', 'contains', $value); |
|
1227
|
|
|
break; |
|
1228
|
|
|
|
|
1229
|
|
|
case 'territorytoregion': |
|
1230
|
|
|
$_temp2 = self::_getFile('supplementalData', '/supplementalData/territoryContainment/group', 'type'); |
|
1231
|
|
|
$_temp = array(); |
|
1232
|
|
|
foreach ($_temp2 as $key => $found) { |
|
1233
|
|
|
$_temp += self::_getFile('supplementalData', '/supplementalData/territoryContainment/group[@type=\'' . $key . '\']', 'contains', $key); |
|
1234
|
|
|
} |
|
1235
|
|
|
$temp = array(); |
|
1236
|
|
|
foreach($_temp as $key => $found) { |
|
1237
|
|
|
$_temp3 = explode(" ", $found); |
|
1238
|
|
|
foreach($_temp3 as $found3) { |
|
1239
|
|
|
if ($found3 !== $value) { |
|
1240
|
|
|
continue; |
|
1241
|
|
|
} |
|
1242
|
|
|
if (!isset($temp[$found3])) { |
|
1243
|
|
|
$temp[$found3] = (string) $key; |
|
1244
|
|
|
} else { |
|
1245
|
|
|
$temp[$found3] .= " " . $key; |
|
1246
|
|
|
} |
|
1247
|
|
|
} |
|
1248
|
|
|
} |
|
1249
|
|
|
break; |
|
1250
|
|
|
|
|
1251
|
|
|
case 'scripttolanguage': |
|
1252
|
|
|
$temp = self::_getFile('supplementalData', '/supplementalData/languageData/language[@type=\'' . $value . '\']', 'scripts', $value); |
|
1253
|
|
|
break; |
|
1254
|
|
|
|
|
1255
|
|
|
case 'languagetoscript': |
|
1256
|
|
|
$_temp2 = self::_getFile('supplementalData', '/supplementalData/languageData/language', 'type'); |
|
1257
|
|
|
$_temp = array(); |
|
1258
|
|
|
foreach ($_temp2 as $key => $found) { |
|
1259
|
|
|
$_temp += self::_getFile('supplementalData', '/supplementalData/languageData/language[@type=\'' . $key . '\']', 'scripts', $key); |
|
1260
|
|
|
} |
|
1261
|
|
|
$temp = array(); |
|
1262
|
|
|
foreach($_temp as $key => $found) { |
|
1263
|
|
|
$_temp3 = explode(" ", $found); |
|
1264
|
|
|
foreach($_temp3 as $found3) { |
|
1265
|
|
|
if ($found3 !== $value) { |
|
1266
|
|
|
continue; |
|
1267
|
|
|
} |
|
1268
|
|
|
if (!isset($temp[$found3])) { |
|
1269
|
|
|
$temp[$found3] = (string) $key; |
|
1270
|
|
|
} else { |
|
1271
|
|
|
$temp[$found3] .= " " . $key; |
|
1272
|
|
|
} |
|
1273
|
|
|
} |
|
1274
|
|
|
} |
|
1275
|
|
|
break; |
|
1276
|
|
|
|
|
1277
|
|
|
case 'territorytolanguage': |
|
1278
|
|
|
$temp = self::_getFile('supplementalData', '/supplementalData/languageData/language[@type=\'' . $value . '\']', 'territories', $value); |
|
1279
|
|
|
break; |
|
1280
|
|
|
|
|
1281
|
|
|
case 'languagetoterritory': |
|
1282
|
|
|
$_temp2 = self::_getFile('supplementalData', '/supplementalData/languageData/language', 'type'); |
|
1283
|
|
|
$_temp = array(); |
|
1284
|
|
|
foreach ($_temp2 as $key => $found) { |
|
1285
|
|
|
$_temp += self::_getFile('supplementalData', '/supplementalData/languageData/language[@type=\'' . $key . '\']', 'territories', $key); |
|
1286
|
|
|
} |
|
1287
|
|
|
$temp = array(); |
|
1288
|
|
|
foreach($_temp as $key => $found) { |
|
1289
|
|
|
$_temp3 = explode(" ", $found); |
|
1290
|
|
|
foreach($_temp3 as $found3) { |
|
1291
|
|
|
if ($found3 !== $value) { |
|
1292
|
|
|
continue; |
|
1293
|
|
|
} |
|
1294
|
|
|
if (!isset($temp[$found3])) { |
|
1295
|
|
|
$temp[$found3] = (string) $key; |
|
1296
|
|
|
} else { |
|
1297
|
|
|
$temp[$found3] .= " " . $key; |
|
1298
|
|
|
} |
|
1299
|
|
|
} |
|
1300
|
|
|
} |
|
1301
|
|
|
break; |
|
1302
|
|
|
|
|
1303
|
|
|
case 'timezonetowindows': |
|
1304
|
|
|
$temp = self::_getFile('supplementalData', '/supplementalData/timezoneData/mapTimezones[@type=\'windows\']/mapZone[@other=\''.$value.'\']', 'type', $value); |
|
1305
|
|
|
break; |
|
1306
|
|
|
|
|
1307
|
|
|
case 'windowstotimezone': |
|
1308
|
|
|
$temp = self::_getFile('supplementalData', '/supplementalData/timezoneData/mapTimezones[@type=\'windows\']/mapZone[@type=\''.$value.'\']', 'other', $value); |
|
1309
|
|
|
break; |
|
1310
|
|
|
|
|
1311
|
|
|
case 'territorytotimezone': |
|
1312
|
|
|
$temp = self::_getFile('supplementalData', '/supplementalData/timezoneData/zoneFormatting/zoneItem[@type=\'' . $value . '\']', 'territory', $value); |
|
1313
|
|
|
break; |
|
1314
|
|
|
|
|
1315
|
|
|
case 'timezonetoterritory': |
|
1316
|
|
|
$temp = self::_getFile('supplementalData', '/supplementalData/timezoneData/zoneFormatting/zoneItem[@territory=\'' . $value . '\']', 'type', $value); |
|
1317
|
|
|
break; |
|
1318
|
|
|
|
|
1319
|
|
|
case 'citytotimezone': |
|
1320
|
|
|
$temp = self::_getFile($locale, '/ldml/dates/timeZoneNames/zone[@type=\'' . $value . '\']/exemplarCity', '', $value); |
|
1321
|
|
|
break; |
|
1322
|
|
|
|
|
1323
|
|
|
case 'timezonetocity': |
|
1324
|
|
|
$_temp = self::_getFile($locale, '/ldml/dates/timeZoneNames/zone', 'type'); |
|
1325
|
|
|
$temp = array(); |
|
1326
|
|
|
foreach($_temp as $key => $found) { |
|
1327
|
|
|
$temp += self::_getFile($locale, '/ldml/dates/timeZoneNames/zone[@type=\'' . $key . '\']/exemplarCity', '', $key); |
|
1328
|
|
|
if (!empty($temp[$key])) { |
|
1329
|
|
|
if ($temp[$key] == $value) { |
|
1330
|
|
|
$temp[$temp[$key]] = $key; |
|
1331
|
|
|
} |
|
1332
|
|
|
} |
|
1333
|
|
|
unset($temp[$key]); |
|
1334
|
|
|
} |
|
1335
|
|
|
break; |
|
1336
|
|
|
|
|
1337
|
|
|
case 'phonetoterritory': |
|
1338
|
|
|
$temp = self::_getFile('telephoneCodeData', '/supplementalData/telephoneCodeData/codesByTerritory[@territory=\'' . $value . '\']/telephoneCountryCode', 'code', $value); |
|
1339
|
|
|
break; |
|
1340
|
|
|
|
|
1341
|
|
|
case 'territorytophone': |
|
1342
|
|
|
$_temp2 = self::_getFile('telephoneCodeData', '/supplementalData/telephoneCodeData/codesByTerritory', 'territory'); |
|
1343
|
|
|
$_temp = array(); |
|
1344
|
|
|
foreach ($_temp2 as $key => $found) { |
|
1345
|
|
|
$_temp += self::_getFile('telephoneCodeData', '/supplementalData/telephoneCodeData/codesByTerritory[@territory=\'' . $key . '\']/telephoneCountryCode', 'code', $key); |
|
1346
|
|
|
} |
|
1347
|
|
|
$temp = array(); |
|
1348
|
|
|
foreach($_temp as $key => $found) { |
|
1349
|
|
|
$_temp3 = explode(" ", $found); |
|
1350
|
|
|
foreach($_temp3 as $found3) { |
|
1351
|
|
|
if ($found3 !== $value) { |
|
1352
|
|
|
continue; |
|
1353
|
|
|
} |
|
1354
|
|
|
if (!isset($temp[$found3])) { |
|
1355
|
|
|
$temp[$found3] = (string) $key; |
|
1356
|
|
|
} else { |
|
1357
|
|
|
$temp[$found3] .= " " . $key; |
|
1358
|
|
|
} |
|
1359
|
|
|
} |
|
1360
|
|
|
} |
|
1361
|
|
|
break; |
|
1362
|
|
|
|
|
1363
|
|
|
case 'numerictoterritory': |
|
1364
|
|
|
$temp = self::_getFile('supplementalData', '/supplementalData/codeMappings/territoryCodes[@type=\''.$value.'\']', 'numeric', $value); |
|
1365
|
|
|
break; |
|
1366
|
|
|
|
|
1367
|
|
|
case 'territorytonumeric': |
|
1368
|
|
|
$temp = self::_getFile('supplementalData', '/supplementalData/codeMappings/territoryCodes[@numeric=\''.$value.'\']', 'type', $value); |
|
1369
|
|
|
break; |
|
1370
|
|
|
|
|
1371
|
|
|
case 'alpha3toterritory': |
|
1372
|
|
|
$temp = self::_getFile('supplementalData', '/supplementalData/codeMappings/territoryCodes[@type=\''.$value.'\']', 'alpha3', $value); |
|
1373
|
|
|
break; |
|
1374
|
|
|
|
|
1375
|
|
|
case 'territorytoalpha3': |
|
1376
|
|
|
$temp = self::_getFile('supplementalData', '/supplementalData/codeMappings/territoryCodes[@alpha3=\''.$value.'\']', 'type', $value); |
|
1377
|
|
|
break; |
|
1378
|
|
|
|
|
1379
|
|
|
case 'postaltoterritory': |
|
1380
|
|
|
$temp = self::_getFile('postalCodeData', '/supplementalData/postalCodeData/postCodeRegex[@territoryId=\'' . $value . '\']', 'territoryId'); |
|
1381
|
|
|
break; |
|
1382
|
|
|
|
|
1383
|
|
|
case 'numberingsystem': |
|
1384
|
|
|
$temp = self::_getFile('numberingSystems', '/supplementalData/numberingSystems/numberingSystem[@id=\'' . strtolower($value) . '\']', 'digits', $value); |
|
1385
|
|
|
break; |
|
1386
|
|
|
|
|
1387
|
|
|
case 'chartofallback': |
|
1388
|
|
|
$_temp = self::_getFile('characters', '/supplementalData/characters/character-fallback/character', 'value'); |
|
1389
|
|
|
foreach ($_temp as $key => $keyvalue) { |
|
1390
|
|
|
$temp2 = self::_getFile('characters', '/supplementalData/characters/character-fallback/character[@value=\'' . $key . '\']/substitute', '', $key); |
|
1391
|
|
|
if (current($temp2) == $value) { |
|
1392
|
|
|
$temp = $key; |
|
1393
|
|
|
} |
|
1394
|
|
|
} |
|
1395
|
|
|
break; |
|
1396
|
|
|
|
|
1397
|
|
|
$temp = self::_getFile('characters', '/supplementalData/characters/character-fallback/character[@value=\'' . $value . '\']/substitute', '', $value); |
|
1398
|
|
|
break; |
|
1399
|
|
|
|
|
1400
|
|
|
case 'fallbacktochar': |
|
1401
|
|
|
$temp = self::_getFile('characters', '/supplementalData/characters/character-fallback/character[@value=\'' . $value . '\']/substitute', ''); |
|
1402
|
|
|
break; |
|
1403
|
|
|
|
|
1404
|
|
|
case 'localeupgrade': |
|
1405
|
|
|
$temp = self::_getFile('likelySubtags', '/supplementalData/likelySubtags/likelySubtag[@from=\'' . $value . '\']', 'to', $value); |
|
1406
|
|
|
break; |
|
1407
|
|
|
|
|
1408
|
|
|
case 'unit': |
|
1409
|
|
|
$temp = self::_getFile($locale, '/ldml/units/unit[@type=\'' . $value[0] . '\']/unitPattern[@count=\'' . $value[1] . '\']', ''); |
|
1410
|
|
|
break; |
|
1411
|
|
|
|
|
1412
|
|
|
default : |
|
1413
|
|
|
require_once 'Zend/Locale/Exception.php'; |
|
1414
|
|
|
throw new Zend_Locale_Exception("Unknown detail ($path) for parsing locale data."); |
|
1415
|
|
|
break; |
|
1416
|
|
|
} |
|
1417
|
|
|
|
|
1418
|
|
|
if (is_array($temp)) { |
|
1419
|
|
|
$temp = current($temp); |
|
1420
|
|
|
} |
|
1421
|
|
|
if (isset(self::$_cache)) { |
|
1422
|
|
|
if (self::$_cacheTags) { |
|
1423
|
|
|
self::$_cache->save( serialize($temp), $id, array('Zend_Locale')); |
|
1424
|
|
|
} else { |
|
1425
|
|
|
self::$_cache->save( serialize($temp), $id); |
|
1426
|
|
|
} |
|
1427
|
|
|
} |
|
1428
|
|
|
|
|
1429
|
|
|
return $temp; |
|
1430
|
|
|
} |
|
1431
|
|
|
|
|
1432
|
|
|
/** |
|
1433
|
|
|
* Returns the set cache |
|
1434
|
|
|
* |
|
1435
|
|
|
* @return Zend_Cache_Core The set cache |
|
1436
|
|
|
*/ |
|
1437
|
|
|
public static function getCache() |
|
1438
|
|
|
{ |
|
1439
|
|
|
return self::$_cache; |
|
1440
|
|
|
} |
|
1441
|
|
|
|
|
1442
|
|
|
/** |
|
1443
|
|
|
* Set a cache for Zend_Locale_Data |
|
1444
|
|
|
* |
|
1445
|
|
|
* @param Zend_Cache_Core $cache A cache frontend |
|
1446
|
|
|
*/ |
|
1447
|
|
|
public static function setCache(Zend_Cache_Core $cache) |
|
1448
|
|
|
{ |
|
1449
|
|
|
self::$_cache = $cache; |
|
1450
|
|
|
self::_getTagSupportForCache(); |
|
1451
|
|
|
} |
|
1452
|
|
|
|
|
1453
|
|
|
/** |
|
1454
|
|
|
* Returns true when a cache is set |
|
1455
|
|
|
* |
|
1456
|
|
|
* @return boolean |
|
1457
|
|
|
*/ |
|
1458
|
|
|
public static function hasCache() |
|
1459
|
|
|
{ |
|
1460
|
|
|
if (self::$_cache !== null) { |
|
1461
|
|
|
return true; |
|
1462
|
|
|
} |
|
1463
|
|
|
|
|
1464
|
|
|
return false; |
|
1465
|
|
|
} |
|
1466
|
|
|
|
|
1467
|
|
|
/** |
|
1468
|
|
|
* Removes any set cache |
|
1469
|
|
|
* |
|
1470
|
|
|
* @return void |
|
1471
|
|
|
*/ |
|
1472
|
|
|
public static function removeCache() |
|
1473
|
|
|
{ |
|
1474
|
|
|
self::$_cache = null; |
|
1475
|
|
|
} |
|
1476
|
|
|
|
|
1477
|
|
|
/** |
|
1478
|
|
|
* Clears all set cache data |
|
1479
|
|
|
* |
|
1480
|
|
|
* @return void |
|
1481
|
|
|
*/ |
|
1482
|
|
|
public static function clearCache() |
|
1483
|
|
|
{ |
|
1484
|
|
|
if (self::$_cacheTags) { |
|
1485
|
|
|
self::$_cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array('Zend_Locale')); |
|
1486
|
|
|
} else { |
|
1487
|
|
|
self::$_cache->clean(Zend_Cache::CLEANING_MODE_ALL); |
|
1488
|
|
|
} |
|
1489
|
|
|
} |
|
1490
|
|
|
|
|
1491
|
|
|
/** |
|
1492
|
|
|
* Disables the cache |
|
1493
|
|
|
* |
|
1494
|
|
|
* @param unknown_type $flag |
|
1495
|
|
|
*/ |
|
1496
|
|
|
public static function disableCache($flag) |
|
1497
|
|
|
{ |
|
1498
|
|
|
self::$_cacheDisabled = (boolean) $flag; |
|
1499
|
|
|
} |
|
1500
|
|
|
|
|
1501
|
|
|
/** |
|
1502
|
|
|
* Internal method to check if the given cache supports tags |
|
1503
|
|
|
* |
|
1504
|
|
|
* @param Zend_Cache $cache |
|
1505
|
|
|
*/ |
|
1506
|
|
|
private static function _getTagSupportForCache() |
|
1507
|
|
|
{ |
|
1508
|
|
|
$backend = self::$_cache->getBackend(); |
|
1509
|
|
|
if ($backend instanceof Zend_Cache_Backend_ExtendedInterface) { |
|
1510
|
|
|
$cacheOptions = $backend->getCapabilities(); |
|
1511
|
|
|
self::$_cacheTags = $cacheOptions['tags']; |
|
1512
|
|
|
} else { |
|
1513
|
|
|
self::$_cacheTags = false; |
|
1514
|
|
|
} |
|
1515
|
|
|
|
|
1516
|
|
|
return self::$_cacheTags; |
|
1517
|
|
|
} |
|
1518
|
|
|
} |
|
1519
|
|
|
|