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 license@zend.com so we can send you a copy immediately.
16 * @package Zend_Locale
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license http://framework.zend.com/license/new-bsd New BSD License
24 * include needed classes
26 require_once 'Zend/Locale.php';
29 * Locale data reader, handles the CLDR
32 * @package Zend_Locale
34 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
35 * @license http://framework.zend.com/license/new-bsd New BSD License
37 class Zend_Locale_Data
45 private static $_ldml = array();
48 * List of values which are collected
53 private static $_list = array();
56 * Internal cache for ldml values
58 * @var Zend_Cache_Core
61 private static $_cache = null;
64 * Internal option, cache disabled
69 private static $_cacheDisabled = false;
72 * Read the content from locale
76 * <delimiter>test</delimiter>
77 * <second type='myone'>content</second>
78 * <second type='mysecond'>content2</second>
79 * <third type='mythird' />
82 * Case 1: _readFile('ar','/ldml/delimiter') -> returns [] = test
83 * Case 1: _readFile('ar','/ldml/second[@type=myone]') -> returns [] = content
84 * Case 2: _readFile('ar','/ldml/second','type') -> returns [myone] = content; [mysecond] = content2
85 * Case 3: _readFile('ar','/ldml/delimiter',,'right') -> returns [right] = test
86 * Case 4: _readFile('ar','/ldml/third','type','myone') -> returns [myone] = mythird
88 * @param string $locale
90 * @param string $attribute
91 * @param string $value
95 private static function _readFile($locale, $path, $attribute, $value, $temp)
97 // without attribute - read all values
98 // with attribute - read only this value
99 if (!empty(self
::$_ldml[(string) $locale])) {
101 $result = self
::$_ldml[(string) $locale]->xpath($path);
102 if (!empty($result)) {
103 foreach ($result as &$found) {
107 if (empty($attribute)) {
109 $temp[] = (string) $found;
110 } else if (empty($temp[(string) $found[$attribute]])){
112 $temp[(string) $found[$attribute]] = (string) $found;
115 } else if (empty ($temp[$value])) {
117 if (empty($attribute)) {
119 $temp[$value] = (string) $found;
122 $temp[$value] = (string) $found[$attribute];
133 * Find possible routing to other path or locale
135 * @param string $locale
136 * @param string $path
137 * @param string $attribute
138 * @param string $value
140 * @throws Zend_Locale_Exception
143 private static function _findRoute($locale, $path, $attribute, $value, &$temp)
145 // load locale file if not already in cache
146 // needed for alias tag when referring to other locale
147 if (empty(self
::$_ldml[(string) $locale])) {
148 $filename = dirname(__FILE__
) . '/Data/' . $locale . '.xml';
149 if (!file_exists($filename)) {
150 require_once 'Zend/Locale/Exception.php';
151 throw new Zend_Locale_Exception("Missing locale file '$filename' for '$locale' locale.");
154 self
::$_ldml[(string) $locale] = simplexml_load_file($filename);
157 // search for 'alias' tag in the search path for redirection
159 $tok = strtok($path, '/');
161 // parse the complete path
162 if (!empty(self
::$_ldml[(string) $locale])) {
163 while ($tok !== false) {
164 $search .= '/' . $tok;
165 if (strpos($search, '[@') !== false) {
166 while (strrpos($search, '[@') > strrpos($search, ']')) {
171 $search = $search . '/' . $tok;
174 $result = self
::$_ldml[(string) $locale]->xpath($search . '/alias');
177 if (!empty($result)) {
179 $source = $result[0]['source'];
180 $newpath = $result[0]['path'];
182 // new path - path //ldml is to ignore
183 if ($newpath != '//ldml') {
184 // other path - parse to make real path
186 while (substr($newpath,0,3) == '../') {
187 $newpath = substr($newpath, 3);
188 $search = substr($search, 0, strrpos($search, '/'));
191 // truncate ../ to realpath otherwise problems with alias
192 $path = $search . '/' . $newpath;
193 while (($tok = strtok('/'))!== false) {
194 $path = $path . '/' . $tok;
198 // reroute to other locale
199 if ($source != 'locale') {
203 $temp = self
::_getFile($locale, $path, $attribute, $value, $temp);
214 * Read the right LDML file
216 * @param string $locale
217 * @param string $path
218 * @param string $attribute
219 * @param string $value
222 private static function _getFile($locale, $path, $attribute = false, $value = false, $temp = array())
224 $result = self
::_findRoute($locale, $path, $attribute, $value, $temp);
226 $temp = self
::_readFile($locale, $path, $attribute, $value, $temp);
229 // parse required locales reversive
230 // example: when given zh_Hans_CN
235 if (($locale != 'root') && ($result)) {
236 $locale = substr($locale, 0, -strlen(strrchr($locale, '_')));
237 if (!empty($locale)) {
238 $temp = self
::_getFile($locale, $path, $attribute, $value, $temp);
240 $temp = self
::_getFile('root', $path, $attribute, $value, $temp);
247 * Find the details for supplemental calendar datas
249 * @param string $locale Locale for Detaildata
250 * @param array $list List to search
251 * @return string Key for Detaildata
253 private static function _calendarDetail($locale, $list)
256 foreach ($list as $key => $value) {
257 if (strpos($locale, '_') !== false) {
258 $locale = substr($locale, strpos($locale, '_') +
1);
260 if (strpos($key, $locale) !== false) {
269 * Internal function for checking the locale
271 * @param string|Zend_Locale $locale Locale to check
274 private static function _checkLocale($locale)
276 if (empty($locale)) {
277 $locale = new Zend_Locale();
280 if (!(Zend_Locale
::isLocale((string) $locale, null, false))) {
281 require_once 'Zend/Locale/Exception.php';
282 throw new Zend_Locale_Exception("Locale (" . (string) $locale . ") is a unknown locale");
285 return (string) $locale;
289 * Read the LDML file, get a array of multipath defined value
291 * @param string $locale
292 * @param string $path
293 * @param string $value
297 public static function getList($locale, $path, $value = false)
299 $locale = self
::_checkLocale($locale);
301 if (!isset(self
::$_cache) && !self
::$_cacheDisabled) {
302 require_once 'Zend/Cache.php';
303 self
::$_cache = Zend_Cache
::factory(
306 array('automatic_serialization' => true),
311 if (is_array($value)) {
312 $val = implode('_' , $value);
315 $val = urlencode($val);
316 $id = strtr('Zend_LocaleL_' . $locale . '_' . $path . '_' . $val, array('-' => '_', '%' => '_', '+' => '_'));
317 if (!self
::$_cacheDisabled && ($result = self
::$_cache->load($id))) {
318 return unserialize($result);
322 switch(strtolower($path)) {
324 $temp = self
::_getFile($locale, '/ldml/localeDisplayNames/languages/language', 'type');
328 $temp = self
::_getFile($locale, '/ldml/localeDisplayNames/scripts/script', 'type');
332 $temp = self
::_getFile($locale, '/ldml/localeDisplayNames/territories/territory', 'type');
334 foreach($temp as $key => $value) {
335 if ((is_numeric($key) === false) and ($key != 'QO') and ($key != 'QU')) {
339 } else if ($value === 2) {
340 foreach($temp as $key => $value) {
341 if (is_numeric($key) or ($key == 'QO') or ($key == 'QU')) {
349 $temp = self
::_getFile($locale, '/ldml/localeDisplayNames/variants/variant', 'type');
353 $temp = self
::_getFile($locale, '/ldml/localeDisplayNames/keys/key', 'type');
358 $temp = self
::_getFile($locale, '/ldml/localeDisplayNames/types/type', 'type');
360 if (($value == 'calendar') or
361 ($value == 'collation') or
362 ($value == 'currency')) {
363 $temp = self
::_getFile($locale, '/ldml/localeDisplayNames/types/type[@key=\'' . $value . '\']', 'type');
365 $temp = self
::_getFile($locale, '/ldml/localeDisplayNames/types/type[@type=\'' . $value . '\']', 'type');
371 $temp = self
::_getFile($locale, '/ldml/layout/orientation', 'lines', 'lines');
372 $temp +
= self
::_getFile($locale, '/ldml/layout/orientation', 'characters', 'characters');
373 $temp +
= self
::_getFile($locale, '/ldml/layout/inList', '', 'inList');
374 $temp +
= self
::_getFile($locale, '/ldml/layout/inText[@type=\'currency\']', '', 'currency');
375 $temp +
= self
::_getFile($locale, '/ldml/layout/inText[@type=\'dayWidth\']', '', 'dayWidth');
376 $temp +
= self
::_getFile($locale, '/ldml/layout/inText[@type=\'fields\']', '', 'fields');
377 $temp +
= self
::_getFile($locale, '/ldml/layout/inText[@type=\'keys\']', '', 'keys');
378 $temp +
= self
::_getFile($locale, '/ldml/layout/inText[@type=\'languages\']', '', 'languages');
379 $temp +
= self
::_getFile($locale, '/ldml/layout/inText[@type=\'long\']', '', 'long');
380 $temp +
= self
::_getFile($locale, '/ldml/layout/inText[@type=\'measurementSystemNames\']', '', 'measurementSystemNames');
381 $temp +
= self
::_getFile($locale, '/ldml/layout/inText[@type=\'monthWidth\']', '', 'monthWidth');
382 $temp +
= self
::_getFile($locale, '/ldml/layout/inText[@type=\'quarterWidth\']', '', 'quarterWidth');
383 $temp +
= self
::_getFile($locale, '/ldml/layout/inText[@type=\'scripts\']', '', 'scripts');
384 $temp +
= self
::_getFile($locale, '/ldml/layout/inText[@type=\'territories\']', '', 'territories');
385 $temp +
= self
::_getFile($locale, '/ldml/layout/inText[@type=\'types\']', '', 'types');
386 $temp +
= self
::_getFile($locale, '/ldml/layout/inText[@type=\'variants\']', '', 'variants');
390 $temp = self
::_getFile($locale, '/ldml/characters/exemplarCharacters', '', 'characters');
391 $temp +
= self
::_getFile($locale, '/ldml/characters/exemplarCharacters[@type=\'auxiliary\']', '', 'auxiliary');
392 $temp +
= self
::_getFile($locale, '/ldml/characters/exemplarCharacters[@type=\'currencySymbol\']', '', 'currencySymbol');
396 $temp = self
::_getFile($locale, '/ldml/delimiters/quotationStart', '', 'quoteStart');
397 $temp +
= self
::_getFile($locale, '/ldml/delimiters/quotationEnd', '', 'quoteEnd');
398 $temp +
= self
::_getFile($locale, '/ldml/delimiters/alternateQuotationStart', '', 'quoteStartAlt');
399 $temp +
= self
::_getFile($locale, '/ldml/delimiters/alternateQuotationEnd', '', 'quoteEndAlt');
403 $temp = self
::_getFile('supplementalData', '/supplementalData/measurementData/measurementSystem[@type=\'metric\']', 'territories', 'metric');
404 $temp +
= self
::_getFile('supplementalData', '/supplementalData/measurementData/measurementSystem[@type=\'US\']', 'territories', 'US');
405 $temp +
= self
::_getFile('supplementalData', '/supplementalData/measurementData/paperSize[@type=\'A4\']', 'territories', 'A4');
406 $temp +
= self
::_getFile('supplementalData', '/supplementalData/measurementData/paperSize[@type=\'US-Letter\']', 'territories', 'US-Letter');
411 $value = "gregorian";
413 $temp = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/default', 'choice', 'context');
414 $temp +
= self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'format\']/default', 'choice', 'default');
415 $temp['format']['abbreviated'] = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'format\']/monthWidth[@type=\'abbreviated\']/month', 'type');
416 $temp['format']['narrow'] = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'format\']/monthWidth[@type=\'narrow\']/month', 'type');
417 $temp['format']['wide'] = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'format\']/monthWidth[@type=\'wide\']/month', 'type');
418 $temp['stand-alone']['abbreviated'] = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'stand-alone\']/monthWidth[@type=\'abbreviated\']/month', 'type');
419 $temp['stand-alone']['narrow'] = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'stand-alone\']/monthWidth[@type=\'narrow\']/month', 'type');
420 $temp['stand-alone']['wide'] = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'stand-alone\']/monthWidth[@type=\'wide\']/month', 'type');
425 $value = array("gregorian", "format", "wide");
427 $temp = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/months/monthContext[@type=\'' . $value[1] . '\']/monthWidth[@type=\'' . $value[2] . '\']/month', 'type');
432 $value = "gregorian";
434 $temp = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/default', 'choice', 'context');
435 $temp +
= self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'format\']/default', 'choice', 'default');
436 $temp['format']['abbreviated'] = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'format\']/dayWidth[@type=\'abbreviated\']/day', 'type');
437 $temp['format']['narrow'] = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'format\']/dayWidth[@type=\'narrow\']/day', 'type');
438 $temp['format']['wide'] = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'format\']/dayWidth[@type=\'wide\']/day', 'type');
439 $temp['stand-alone']['abbreviated'] = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'stand-alone\']/dayWidth[@type=\'abbreviated\']/day', 'type');
440 $temp['stand-alone']['narrow'] = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'stand-alone\']/dayWidth[@type=\'narrow\']/day', 'type');
441 $temp['stand-alone']['wide'] = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'stand-alone\']/dayWidth[@type=\'wide\']/day', 'type');
446 $value = array("gregorian", "format", "wide");
448 $temp = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/days/dayContext[@type=\'' . $value[1] . '\']/dayWidth[@type=\'' . $value[2] . '\']/day', 'type');
452 $minDays = self
::_calendarDetail($locale, self
::_getFile('supplementalData', '/supplementalData/weekData/minDays', 'territories'));
453 $firstDay = self
::_calendarDetail($locale, self
::_getFile('supplementalData', '/supplementalData/weekData/firstDay', 'territories'));
454 $weekStart = self
::_calendarDetail($locale, self
::_getFile('supplementalData', '/supplementalData/weekData/weekendStart', 'territories'));
455 $weekEnd = self
::_calendarDetail($locale, self
::_getFile('supplementalData', '/supplementalData/weekData/weekendEnd', 'territories'));
457 $temp = self
::_getFile('supplementalData', "/supplementalData/weekData/minDays[@territories='" . $minDays . "']", 'count', 'minDays');
458 $temp +
= self
::_getFile('supplementalData', "/supplementalData/weekData/firstDay[@territories='" . $firstDay . "']", 'day', 'firstDay');
459 $temp +
= self
::_getFile('supplementalData', "/supplementalData/weekData/weekendStart[@territories='" . $weekStart . "']", 'day', 'weekendStart');
460 $temp +
= self
::_getFile('supplementalData', "/supplementalData/weekData/weekendEnd[@territories='" . $weekEnd . "']", 'day', 'weekendEnd');
465 $value = "gregorian";
467 $temp['format']['abbreviated'] = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/quarters/quarterContext[@type=\'format\']/quarterWidth[@type=\'abbreviated\']/quarter', 'type');
468 $temp['format']['narrow'] = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/quarters/quarterContext[@type=\'format\']/quarterWidth[@type=\'narrow\']/quarter', 'type');
469 $temp['format']['wide'] = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/quarters/quarterContext[@type=\'format\']/quarterWidth[@type=\'wide\']/quarter', 'type');
470 $temp['stand-alone']['abbreviated'] = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/quarters/quarterContext[@type=\'stand-alone\']/quarterWidth[@type=\'abbreviated\']/quarter', 'type');
471 $temp['stand-alone']['narrow'] = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/quarters/quarterContext[@type=\'stand-alone\']/quarterWidth[@type=\'narrow\']/quarter', 'type');
472 $temp['stand-alone']['wide'] = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/quarters/quarterContext[@type=\'stand-alone\']/quarterWidth[@type=\'wide\']/quarter', 'type');
477 $value = array("gregorian", "format", "wide");
479 $temp = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/quarters/quarterContext[@type=\'' . $value[1] . '\']/quarterWidth[@type=\'' . $value[2] . '\']/quarter', 'type');
484 $value = "gregorian";
486 $temp['names'] = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/eras/eraNames/era', 'type');
487 $temp['abbreviated'] = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/eras/eraAbbr/era', 'type');
488 $temp['narrow'] = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/eras/eraNarrow/era', 'type');
493 $value = array("gregorian", "Abbr");
495 $temp = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/eras/era' . $value[1] . '/era', 'type');
500 $value = "gregorian";
502 $temp = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateFormats/dateFormatLength[@type=\'full\']/dateFormat/pattern', '', 'full');
503 $temp +
= self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateFormats/dateFormatLength[@type=\'long\']/dateFormat/pattern', '', 'long');
504 $temp +
= self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateFormats/dateFormatLength[@type=\'medium\']/dateFormat/pattern', '', 'medium');
505 $temp +
= self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateFormats/dateFormatLength[@type=\'short\']/dateFormat/pattern', '', 'short');
510 $value = "gregorian";
512 $temp = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/timeFormats/timeFormatLength[@type=\'full\']/timeFormat/pattern', '', 'full');
513 $temp +
= self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/timeFormats/timeFormatLength[@type=\'long\']/timeFormat/pattern', '', 'long');
514 $temp +
= self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/timeFormats/timeFormatLength[@type=\'medium\']/timeFormat/pattern', '', 'medium');
515 $temp +
= self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/timeFormats/timeFormatLength[@type=\'short\']/timeFormat/pattern', '', 'short');
520 $value = "gregorian";
523 $timefull = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/timeFormats/timeFormatLength[@type=\'full\']/timeFormat/pattern', '', 'full');
524 $timelong = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/timeFormats/timeFormatLength[@type=\'long\']/timeFormat/pattern', '', 'long');
525 $timemedi = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/timeFormats/timeFormatLength[@type=\'medium\']/timeFormat/pattern', '', 'medi');
526 $timeshor = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/timeFormats/timeFormatLength[@type=\'short\']/timeFormat/pattern', '', 'shor');
528 $datefull = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateFormats/dateFormatLength[@type=\'full\']/dateFormat/pattern', '', 'full');
529 $datelong = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateFormats/dateFormatLength[@type=\'long\']/dateFormat/pattern', '', 'long');
530 $datemedi = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateFormats/dateFormatLength[@type=\'medium\']/dateFormat/pattern', '', 'medi');
531 $dateshor = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateFormats/dateFormatLength[@type=\'short\']/dateFormat/pattern', '', 'shor');
533 $full = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateTimeFormats/dateTimeFormatLength[@type=\'full\']/dateTimeFormat/pattern', '', 'full');
534 $long = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateTimeFormats/dateTimeFormatLength[@type=\'long\']/dateTimeFormat/pattern', '', 'long');
535 $medi = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateTimeFormats/dateTimeFormatLength[@type=\'medium\']/dateTimeFormat/pattern', '', 'medi');
536 $shor = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateTimeFormats/dateTimeFormatLength[@type=\'short\']/dateTimeFormat/pattern', '', 'shor');
538 $temp['full'] = str_replace(array('{0}', '{1}'), array($timefull['full'], $datefull['full']), $full['full']);
539 $temp['long'] = str_replace(array('{0}', '{1}'), array($timelong['long'], $datelong['long']), $long['long']);
540 $temp['medium'] = str_replace(array('{0}', '{1}'), array($timemedi['medi'], $datemedi['medi']), $medi['medi']);
541 $temp['short'] = str_replace(array('{0}', '{1}'), array($timeshor['shor'], $dateshor['shor']), $shor['shor']);
546 $value = "gregorian";
548 $_temp = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateTimeFormats/availableFormats/dateFormatItem', 'id');
549 foreach($_temp as $key => $found) {
550 $temp +
= self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateTimeFormats/availableFormats/dateFormatItem[@id=\'' . $key . '\']', '', $key);
556 $value = "gregorian";
558 $_temp = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateTimeFormats/intervalFormats/intervalFormatItem', 'id');
559 foreach($_temp as $key => $found) {
560 $temp[$key] = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateTimeFormats/intervalFormats/intervalFormatItem[@id=\'' . $key . '\']/greatestDifference', 'id');
566 $value = "gregorian";
568 $temp2 = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/fields/field', 'type');
569 foreach ($temp2 as $key => $keyvalue) {
570 $temp +
= self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/fields/field[@type=\'' . $key . '\']/displayName', '', $key);
576 $value = "gregorian";
578 $temp = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/fields/field/relative', 'type');
582 $temp = self
::_getFile($locale, '/ldml/numbers/symbols/decimal', '', 'decimal');
583 $temp +
= self
::_getFile($locale, '/ldml/numbers/symbols/group', '', 'group');
584 $temp +
= self
::_getFile($locale, '/ldml/numbers/symbols/list', '', 'list');
585 $temp +
= self
::_getFile($locale, '/ldml/numbers/symbols/percentSign', '', 'percent');
586 $temp +
= self
::_getFile($locale, '/ldml/numbers/symbols/nativeZeroDigit', '', 'zero');
587 $temp +
= self
::_getFile($locale, '/ldml/numbers/symbols/patternDigit', '', 'pattern');
588 $temp +
= self
::_getFile($locale, '/ldml/numbers/symbols/plusSign', '', 'plus');
589 $temp +
= self
::_getFile($locale, '/ldml/numbers/symbols/minusSign', '', 'minus');
590 $temp +
= self
::_getFile($locale, '/ldml/numbers/symbols/exponential', '', 'exponent');
591 $temp +
= self
::_getFile($locale, '/ldml/numbers/symbols/perMille', '', 'mille');
592 $temp +
= self
::_getFile($locale, '/ldml/numbers/symbols/infinity', '', 'infinity');
593 $temp +
= self
::_getFile($locale, '/ldml/numbers/symbols/nan', '', 'nan');
596 case 'nametocurrency':
597 $_temp = self
::_getFile($locale, '/ldml/numbers/currencies/currency', 'type');
598 foreach ($_temp as $key => $found) {
599 $temp +
= self
::_getFile($locale, '/ldml/numbers/currencies/currency[@type=\'' . $key . '\']/displayName', '', $key);
603 case 'currencytoname':
604 $_temp = self
::_getFile($locale, '/ldml/numbers/currencies/currency', 'type');
605 foreach ($_temp as $key => $keyvalue) {
606 $val = self
::_getFile($locale, '/ldml/numbers/currencies/currency[@type=\'' . $key . '\']/displayName', '', $key);
607 if (!isset($val[$key])) {
610 if (!isset($temp[$val[$key]])) {
611 $temp[$val[$key]] = $key;
613 $temp[$val[$key]] .= " " . $key;
618 case 'currencysymbol':
619 $_temp = self
::_getFile($locale, '/ldml/numbers/currencies/currency', 'type');
620 foreach ($_temp as $key => $found) {
621 $temp +
= self
::_getFile($locale, '/ldml/numbers/currencies/currency[@type=\'' . $key . '\']/symbol', '', $key);
626 $temp = self
::_getFile($locale, '/ldml/posix/messages/yesstr', '', 'yes');
627 $temp +
= self
::_getFile($locale, '/ldml/posix/messages/nostr', '', 'no');
630 case 'currencyfraction':
631 $_temp = self
::_getFile('supplementalData', '/supplementalData/currencyData/fractions/info', 'iso4217');
632 foreach ($_temp as $key => $found) {
633 $temp +
= self
::_getFile('supplementalData', '/supplementalData/currencyData/fractions/info[@iso4217=\'' . $key . '\']', 'digits', $key);
637 case 'currencyrounding':
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 . '\']', 'rounding', $key);
644 case 'currencytoregion':
645 $_temp = self
::_getFile('supplementalData', '/supplementalData/currencyData/region', 'iso3166');
646 foreach ($_temp as $key => $keyvalue) {
647 $temp +
= self
::_getFile('supplementalData', '/supplementalData/currencyData/region[@iso3166=\'' . $key . '\']/currency', 'iso4217', $key);
651 case 'regiontocurrency':
652 $_temp = self
::_getFile('supplementalData', '/supplementalData/currencyData/region', 'iso3166');
653 foreach ($_temp as $key => $keyvalue) {
654 $val = self
::_getFile('supplementalData', '/supplementalData/currencyData/region[@iso3166=\'' . $key . '\']/currency', 'iso4217', $key);
655 if (!isset($val[$key])) {
658 if (!isset($temp[$val[$key]])) {
659 $temp[$val[$key]] = $key;
661 $temp[$val[$key]] .= " " . $key;
666 case 'regiontoterritory':
667 $_temp = self
::_getFile('supplementalData', '/supplementalData/territoryContainment/group', 'type');
668 foreach ($_temp as $key => $found) {
669 $temp +
= self
::_getFile('supplementalData', '/supplementalData/territoryContainment/group[@type=\'' . $key . '\']', 'contains', $key);
673 case 'territorytoregion':
674 $_temp2 = self
::_getFile('supplementalData', '/supplementalData/territoryContainment/group', 'type');
676 foreach ($_temp2 as $key => $found) {
677 $_temp +
= self
::_getFile('supplementalData', '/supplementalData/territoryContainment/group[@type=\'' . $key . '\']', 'contains', $key);
679 foreach($_temp as $key => $found) {
680 $_temp3 = explode(" ", $found);
681 foreach($_temp3 as $found3) {
682 if (!isset($temp[$found3])) {
683 $temp[$found3] = (string) $key;
685 $temp[$found3] .= " " . $key;
691 case 'scripttolanguage':
692 $_temp = self
::_getFile('supplementalData', '/supplementalData/languageData/language', 'type');
693 foreach ($_temp as $key => $found) {
694 $temp +
= self
::_getFile('supplementalData', '/supplementalData/languageData/language[@type=\'' . $key . '\']', 'scripts', $key);
695 if (empty($temp[$key])) {
701 case 'languagetoscript':
702 $_temp2 = self
::_getFile('supplementalData', '/supplementalData/languageData/language', 'type');
704 foreach ($_temp2 as $key => $found) {
705 $_temp +
= self
::_getFile('supplementalData', '/supplementalData/languageData/language[@type=\'' . $key . '\']', 'scripts', $key);
707 foreach($_temp as $key => $found) {
708 $_temp3 = explode(" ", $found);
709 foreach($_temp3 as $found3) {
710 if (empty($found3)) {
713 if (!isset($temp[$found3])) {
714 $temp[$found3] = (string) $key;
716 $temp[$found3] .= " " . $key;
722 case 'territorytolanguage':
723 $_temp = self
::_getFile('supplementalData', '/supplementalData/languageData/language', 'type');
724 foreach ($_temp as $key => $found) {
725 $temp +
= self
::_getFile('supplementalData', '/supplementalData/languageData/language[@type=\'' . $key . '\']', 'territories', $key);
726 if (empty($temp[$key])) {
732 case 'languagetoterritory':
733 $_temp2 = self
::_getFile('supplementalData', '/supplementalData/languageData/language', 'type');
735 foreach ($_temp2 as $key => $found) {
736 $_temp +
= self
::_getFile('supplementalData', '/supplementalData/languageData/language[@type=\'' . $key . '\']', 'territories', $key);
738 foreach($_temp as $key => $found) {
739 $_temp3 = explode(" ", $found);
740 foreach($_temp3 as $found3) {
741 if (empty($found3)) {
744 if (!isset($temp[$found3])) {
745 $temp[$found3] = (string) $key;
747 $temp[$found3] .= " " . $key;
753 case 'timezonetowindows':
754 $_temp = self
::_getFile('supplementalData', '/supplementalData/timezoneData/mapTimezones[@type=\'windows\']/mapZone', 'other');
755 foreach ($_temp as $key => $found) {
756 $temp +
= self
::_getFile('supplementalData', '/supplementalData/timezoneData/mapTimezones[@type=\'windows\']/mapZone[@other=\'' . $key . '\']', 'type', $key);
760 case 'windowstotimezone':
761 $_temp = self
::_getFile('supplementalData', '/supplementalData/timezoneData/mapTimezones[@type=\'windows\']/mapZone', 'type');
762 foreach ($_temp as $key => $found) {
763 $temp +
= self
::_getFile('supplementalData', '/supplementalData/timezoneData/mapTimezones[@type=\'windows\']/mapZone[@type=\'' .$key . '\']', 'other', $key);
767 case 'territorytotimezone':
768 $_temp = self
::_getFile('supplementalData', '/supplementalData/timezoneData/zoneFormatting/zoneItem', 'type');
769 foreach ($_temp as $key => $found) {
770 $temp +
= self
::_getFile('supplementalData', '/supplementalData/timezoneData/zoneFormatting/zoneItem[@type=\'' . $key . '\']', 'territory', $key);
774 case 'timezonetoterritory':
775 $_temp = self
::_getFile('supplementalData', '/supplementalData/timezoneData/zoneFormatting/zoneItem', 'territory');
776 foreach ($_temp as $key => $found) {
777 $temp +
= self
::_getFile('supplementalData', '/supplementalData/timezoneData/zoneFormatting/zoneItem[@territory=\'' . $key . '\']', 'type', $key);
781 case 'citytotimezone':
782 $_temp = self
::_getFile($locale, '/ldml/dates/timeZoneNames/zone', 'type');
783 foreach($_temp as $key => $found) {
784 $temp +
= self
::_getFile($locale, '/ldml/dates/timeZoneNames/zone[@type=\'' . $key . '\']/exemplarCity', '', $key);
788 case 'timezonetocity':
789 $_temp = self
::_getFile($locale, '/ldml/dates/timeZoneNames/zone', 'type');
791 foreach($_temp as $key => $found) {
792 $temp +
= self
::_getFile($locale, '/ldml/dates/timeZoneNames/zone[@type=\'' . $key . '\']/exemplarCity', '', $key);
793 if (!empty($temp[$key])) {
794 $temp[$temp[$key]] = $key;
800 case 'phonetoterritory':
801 $_temp = self
::_getFile('telephoneCodeData', '/supplementalData/telephoneCodeData/codesByTerritory', 'territory');
802 foreach ($_temp as $key => $keyvalue) {
803 $temp +
= self
::_getFile('telephoneCodeData', '/supplementalData/telephoneCodeData/codesByTerritory[@territory=\'' . $key . '\']/telephoneCountryCode', 'code', $key);
807 case 'territorytophone':
808 $_temp = self
::_getFile('telephoneCodeData', '/supplementalData/telephoneCodeData/codesByTerritory', 'territory');
809 foreach ($_temp as $key => $keyvalue) {
810 $val = self
::_getFile('telephoneCodeData', '/supplementalData/telephoneCodeData/codesByTerritory[@territory=\'' . $key . '\']/telephoneCountryCode', 'code', $key);
811 if (!isset($val[$key])) {
814 if (!isset($temp[$val[$key]])) {
815 $temp[$val[$key]] = $key;
817 $temp[$val[$key]] .= " " . $key;
822 case 'numerictoterritory':
823 $_temp = self
::_getFile('supplementalData', '/supplementalData/codeMappings/territoryCodes', 'type');
824 foreach ($_temp as $key => $keyvalue) {
825 $temp +
= self
::_getFile('supplementalData', '/supplementalData/codeMappings/territoryCodes[@type=\'' . $key . '\']', 'numeric', $key);
829 case 'territorytonumeric':
830 $_temp = self
::_getFile('supplementalData', '/supplementalData/codeMappings/territoryCodes', 'numeric');
831 foreach ($_temp as $key => $keyvalue) {
832 $temp +
= self
::_getFile('supplementalData', '/supplementalData/codeMappings/territoryCodes[@numeric=\'' . $key . '\']', 'type', $key);
836 case 'alpha3toterritory':
837 $_temp = self
::_getFile('supplementalData', '/supplementalData/codeMappings/territoryCodes', 'type');
838 foreach ($_temp as $key => $keyvalue) {
839 $temp +
= self
::_getFile('supplementalData', '/supplementalData/codeMappings/territoryCodes[@type=\'' . $key . '\']', 'alpha3', $key);
843 case 'territorytoalpha3':
844 $_temp = self
::_getFile('supplementalData', '/supplementalData/codeMappings/territoryCodes', 'alpha3');
845 foreach ($_temp as $key => $keyvalue) {
846 $temp +
= self
::_getFile('supplementalData', '/supplementalData/codeMappings/territoryCodes[@alpha3=\'' . $key . '\']', 'type', $key);
850 case 'postaltoterritory':
851 $_temp = self
::_getFile('postalCodeData', '/supplementalData/postalCodeData/postCodeRegex', 'territoryId');
852 foreach ($_temp as $key => $keyvalue) {
853 $temp +
= self
::_getFile('postalCodeData', '/supplementalData/postalCodeData/postCodeRegex[@territoryId=\'' . $key . '\']', 'territoryId');
857 case 'numberingsystem':
858 $_temp = self
::_getFile('numberingSystems', '/supplementalData/numberingSystems/numberingSystem', 'id');
859 foreach ($_temp as $key => $keyvalue) {
860 $temp +
= self
::_getFile('numberingSystems', '/supplementalData/numberingSystems/numberingSystem[@id=\'' . $key . '\']', 'digits', $key);
861 if (empty($temp[$key])) {
867 case 'chartofallback':
868 $_temp = self
::_getFile('characters', '/supplementalData/characters/character-fallback/character', 'value');
869 foreach ($_temp as $key => $keyvalue) {
870 $temp2 = self
::_getFile('characters', '/supplementalData/characters/character-fallback/character[@value=\'' . $key . '\']/substitute', '', $key);
871 $temp[current($temp2)] = $key;
875 case 'fallbacktochar':
876 $_temp = self
::_getFile('characters', '/supplementalData/characters/character-fallback/character', 'value');
877 foreach ($_temp as $key => $keyvalue) {
878 $temp +
= self
::_getFile('characters', '/supplementalData/characters/character-fallback/character[@value=\'' . $key . '\']/substitute', '', $key);
882 case 'localeupgrade':
883 $_temp = self
::_getFile('likelySubtags', '/supplementalData/likelySubtags/likelySubtag', 'from');
884 foreach ($_temp as $key => $keyvalue) {
885 $temp +
= self
::_getFile('likelySubtags', '/supplementalData/likelySubtags/likelySubtag[@from=\'' . $key . '\']', 'to', $key);
890 $_temp = self
::_getFile($locale, '/ldml/units/unit', 'type');
891 foreach($_temp as $key => $keyvalue) {
892 $_temp2 = self
::_getFile($locale, '/ldml/units/unit[@type=\'' . $key . '\']/unitPattern', 'count');
893 $temp[$key] = $_temp2;
898 require_once 'Zend/Locale/Exception.php';
899 throw new Zend_Locale_Exception("Unknown list ($path) for parsing locale data.");
903 if (isset(self
::$_cache)) {
904 self
::$_cache->save( serialize($temp), $id);
911 * Read the LDML file, get a single path defined value
913 * @param string $locale
914 * @param string $path
915 * @param string $value
919 public static function getContent($locale, $path, $value = false)
921 $locale = self
::_checkLocale($locale);
923 if (!isset(self
::$_cache) && !self
::$_cacheDisabled) {
924 require_once 'Zend/Cache.php';
925 self
::$_cache = Zend_Cache
::factory(
928 array('automatic_serialization' => true),
933 if (is_array($value)) {
934 $val = implode('_' , $value);
936 $val = urlencode($val);
937 $id = strtr('Zend_LocaleC_' . $locale . '_' . $path . '_' . $val, array('-' => '_', '%' => '_', '+' => '_'));
938 if (!self
::$_cacheDisabled && ($result = self
::$_cache->load($id))) {
939 return unserialize($result);
942 switch(strtolower($path)) {
944 $temp = self
::_getFile($locale, '/ldml/localeDisplayNames/languages/language[@type=\'' . $value . '\']', 'type');
948 $temp = self
::_getFile($locale, '/ldml/localeDisplayNames/scripts/script[@type=\'' . $value . '\']', 'type');
953 $temp = self
::_getFile($locale, '/ldml/localeDisplayNames/territories/territory[@type=\'' . $value . '\']', 'type');
957 $temp = self
::_getFile($locale, '/ldml/localeDisplayNames/variants/variant[@type=\'' . $value . '\']', 'type');
961 $temp = self
::_getFile($locale, '/ldml/localeDisplayNames/keys/key[@type=\'' . $value . '\']', 'type');
964 case 'defaultcalendar':
965 $temp = self
::_getFile($locale, '/ldml/dates/calendars/default', 'choice', 'default');
969 if (empty ($value)) {
970 $value = "gregorian";
972 $temp = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/default', 'choice', 'context');
976 if (empty ($value)) {
977 $value = "gregorian";
979 $temp = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'format\']/default', 'choice', 'default');
983 if (!is_array($value)) {
985 $value = array("gregorian", "format", "wide", $temp);
987 $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');
992 $value = "gregorian";
994 $temp = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/default', 'choice', 'context');
999 $value = "gregorian";
1001 $temp = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'format\']/default', 'choice', 'default');
1005 if (!is_array($value)) {
1007 $value = array("gregorian", "format", "wide", $temp);
1009 $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');
1013 if (!is_array($value)) {
1015 $value = array("gregorian", "format", "wide", $temp);
1017 $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');
1021 if (empty($value)) {
1022 $value = "gregorian";
1024 $temp = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/am', '', 'am');
1028 if (empty($value)) {
1029 $value = "gregorian";
1031 $temp = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/pm', '', 'pm');
1035 if (!is_array($value)) {
1037 $value = array("gregorian", "Abbr", $temp);
1039 $temp = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/eras/era' . $value[1] . '/era[@type=\'' . $value[2] . '\']', 'type');
1043 if (empty($value)) {
1044 $value = "gregorian";
1046 $temp = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateFormats/default', 'choice', 'default');
1050 if (empty($value)) {
1051 $value = array("gregorian", "medium");
1053 if (!is_array($value)) {
1055 $value = array("gregorian", $temp);
1057 $temp = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/dateFormats/dateFormatLength[@type=\'' . $value[1] . '\']/dateFormat/pattern', '', 'pattern');
1061 if (empty($value)) {
1062 $value = "gregorian";
1064 $temp = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/timeFormats/default', 'choice', 'default');
1068 if (empty($value)) {
1069 $value = array("gregorian", "medium");
1071 if (!is_array($value)) {
1073 $value = array("gregorian", $temp);
1075 $temp = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/timeFormats/timeFormatLength[@type=\'' . $value[1] . '\']/timeFormat/pattern', '', 'pattern');
1079 if (empty($value)) {
1080 $value = array("gregorian", "medium");
1082 if (!is_array($value)) {
1084 $value = array("gregorian", $temp);
1087 $date = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/dateFormats/dateFormatLength[@type=\'' . $value[1] . '\']/dateFormat/pattern', '', 'pattern');
1088 $time = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/timeFormats/timeFormatLength[@type=\'' . $value[1] . '\']/timeFormat/pattern', '', 'pattern');
1089 $datetime = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/dateTimeFormats/dateTimeFormatLength[@type=\'' . $value[1] . '\']/dateTimeFormat/pattern', '', 'pattern');
1090 $temp = str_replace(array('{0}', '{1}'), array(current($time), current($date)), current($datetime));
1094 if (empty($value)) {
1095 $value = array("gregorian", "yyMMdd");
1097 if (!is_array($value)) {
1099 $value = array("gregorian", $temp);
1101 $temp = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/dateTimeFormats/availableFormats/dateFormatItem[@id=\'' . $value[1] . '\']', '');
1104 case 'dateinterval':
1105 if (empty($value)) {
1106 $value = array("gregorian", "yMd", "y");
1108 if (!is_array($value)) {
1110 $value = array("gregorian", $temp, $temp[0]);
1112 $temp = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/dateTimeFormats/intervalFormats/intervalFormatItem[@id=\'' . $value[1] . '\']/greatestDifference[@id=\'' . $value[2] . '\']', '');
1116 if (!is_array($value)) {
1118 $value = array("gregorian", $temp);
1120 $temp = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/fields/field[@type=\'' . $value[1] . '\']/displayName', '', $value[1]);
1124 if (!is_array($value)) {
1126 $value = array("gregorian", $temp);
1128 $temp = self
::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/fields/field/relative[@type=\'' . $value[1] . '\']', '', $value[1]);
1131 case 'decimalnumber':
1132 $temp = self
::_getFile($locale, '/ldml/numbers/decimalFormats/decimalFormatLength/decimalFormat/pattern', '', 'default');
1135 case 'scientificnumber':
1136 $temp = self
::_getFile($locale, '/ldml/numbers/scientificFormats/scientificFormatLength/scientificFormat/pattern', '', 'default');
1139 case 'percentnumber':
1140 $temp = self
::_getFile($locale, '/ldml/numbers/percentFormats/percentFormatLength/percentFormat/pattern', '', 'default');
1143 case 'currencynumber':
1144 $temp = self
::_getFile($locale, '/ldml/numbers/currencyFormats/currencyFormatLength/currencyFormat/pattern', '', 'default');
1147 case 'nametocurrency':
1148 $temp = self
::_getFile($locale, '/ldml/numbers/currencies/currency[@type=\'' . $value . '\']/displayName', '', $value);
1151 case 'currencytoname':
1152 $temp = self
::_getFile($locale, '/ldml/numbers/currencies/currency[@type=\'' . $value . '\']/displayName', '', $value);
1153 $_temp = self
::_getFile($locale, '/ldml/numbers/currencies/currency', 'type');
1155 foreach ($_temp as $key => $keyvalue) {
1156 $val = self
::_getFile($locale, '/ldml/numbers/currencies/currency[@type=\'' . $key . '\']/displayName', '', $key);
1157 if (!isset($val[$key]) or ($val[$key] != $value)) {
1160 if (!isset($temp[$val[$key]])) {
1161 $temp[$val[$key]] = $key;
1163 $temp[$val[$key]] .= " " . $key;
1168 case 'currencysymbol':
1169 $temp = self
::_getFile($locale, '/ldml/numbers/currencies/currency[@type=\'' . $value . '\']/symbol', '', $value);
1173 $temp = self
::_getFile($locale, '/ldml/posix/messages/' . $value . 'str', '', $value);
1176 case 'currencyfraction':
1177 if (empty($value)) {
1180 $temp = self
::_getFile('supplementalData', '/supplementalData/currencyData/fractions/info[@iso4217=\'' . $value . '\']', 'digits', 'digits');
1183 case 'currencyrounding':
1184 if (empty($value)) {
1187 $temp = self
::_getFile('supplementalData', '/supplementalData/currencyData/fractions/info[@iso4217=\'' . $value . '\']', 'rounding', 'rounding');
1190 case 'currencytoregion':
1191 $temp = self
::_getFile('supplementalData', '/supplementalData/currencyData/region[@iso3166=\'' . $value . '\']/currency', 'iso4217', $value);
1194 case 'regiontocurrency':
1195 $_temp = self
::_getFile('supplementalData', '/supplementalData/currencyData/region', 'iso3166');
1197 foreach ($_temp as $key => $keyvalue) {
1198 $val = self
::_getFile('supplementalData', '/supplementalData/currencyData/region[@iso3166=\'' . $key . '\']/currency', 'iso4217', $key);
1199 if (!isset($val[$key]) or ($val[$key] != $value)) {
1202 if (!isset($temp[$val[$key]])) {
1203 $temp[$val[$key]] = $key;
1205 $temp[$val[$key]] .= " " . $key;
1210 case 'regiontoterritory':
1211 $temp = self
::_getFile('supplementalData', '/supplementalData/territoryContainment/group[@type=\'' . $value . '\']', 'contains', $value);
1214 case 'territorytoregion':
1215 $_temp2 = self
::_getFile('supplementalData', '/supplementalData/territoryContainment/group', 'type');
1217 foreach ($_temp2 as $key => $found) {
1218 $_temp +
= self
::_getFile('supplementalData', '/supplementalData/territoryContainment/group[@type=\'' . $key . '\']', 'contains', $key);
1221 foreach($_temp as $key => $found) {
1222 $_temp3 = explode(" ", $found);
1223 foreach($_temp3 as $found3) {
1224 if ($found3 !== $value) {
1227 if (!isset($temp[$found3])) {
1228 $temp[$found3] = (string) $key;
1230 $temp[$found3] .= " " . $key;
1236 case 'scripttolanguage':
1237 $temp = self
::_getFile('supplementalData', '/supplementalData/languageData/language[@type=\'' . $value . '\']', 'scripts', $value);
1240 case 'languagetoscript':
1241 $_temp2 = self
::_getFile('supplementalData', '/supplementalData/languageData/language', 'type');
1243 foreach ($_temp2 as $key => $found) {
1244 $_temp +
= self
::_getFile('supplementalData', '/supplementalData/languageData/language[@type=\'' . $key . '\']', 'scripts', $key);
1247 foreach($_temp as $key => $found) {
1248 $_temp3 = explode(" ", $found);
1249 foreach($_temp3 as $found3) {
1250 if ($found3 !== $value) {
1253 if (!isset($temp[$found3])) {
1254 $temp[$found3] = (string) $key;
1256 $temp[$found3] .= " " . $key;
1262 case 'territorytolanguage':
1263 $temp = self
::_getFile('supplementalData', '/supplementalData/languageData/language[@type=\'' . $value . '\']', 'territories', $value);
1266 case 'languagetoterritory':
1267 $_temp2 = self
::_getFile('supplementalData', '/supplementalData/languageData/language', 'type');
1269 foreach ($_temp2 as $key => $found) {
1270 $_temp +
= self
::_getFile('supplementalData', '/supplementalData/languageData/language[@type=\'' . $key . '\']', 'territories', $key);
1273 foreach($_temp as $key => $found) {
1274 $_temp3 = explode(" ", $found);
1275 foreach($_temp3 as $found3) {
1276 if ($found3 !== $value) {
1279 if (!isset($temp[$found3])) {
1280 $temp[$found3] = (string) $key;
1282 $temp[$found3] .= " " . $key;
1288 case 'timezonetowindows':
1289 $temp = self
::_getFile('supplementalData', '/supplementalData/timezoneData/mapTimezones[@type=\'windows\']/mapZone[@other=\''.$value.'\']', 'type', $value);
1292 case 'windowstotimezone':
1293 $temp = self
::_getFile('supplementalData', '/supplementalData/timezoneData/mapTimezones[@type=\'windows\']/mapZone[@type=\''.$value.'\']', 'other', $value);
1296 case 'territorytotimezone':
1297 $temp = self
::_getFile('supplementalData', '/supplementalData/timezoneData/zoneFormatting/zoneItem[@type=\'' . $value . '\']', 'territory', $value);
1300 case 'timezonetoterritory':
1301 $temp = self
::_getFile('supplementalData', '/supplementalData/timezoneData/zoneFormatting/zoneItem[@territory=\'' . $value . '\']', 'type', $value);
1304 case 'citytotimezone':
1305 $temp = self
::_getFile($locale, '/ldml/dates/timeZoneNames/zone[@type=\'' . $value . '\']/exemplarCity', '', $value);
1308 case 'timezonetocity':
1309 $_temp = self
::_getFile($locale, '/ldml/dates/timeZoneNames/zone', 'type');
1311 foreach($_temp as $key => $found) {
1312 $temp +
= self
::_getFile($locale, '/ldml/dates/timeZoneNames/zone[@type=\'' . $key . '\']/exemplarCity', '', $key);
1313 if (!empty($temp[$key])) {
1314 if ($temp[$key] == $value) {
1315 $temp[$temp[$key]] = $key;
1322 case 'phonetoterritory':
1323 $temp = self
::_getFile('telephoneCodeData', '/supplementalData/telephoneCodeData/codesByTerritory[@territory=\'' . $value . '\']/telephoneCountryCode', 'code', $value);
1326 case 'territorytophone':
1327 $_temp2 = self
::_getFile('telephoneCodeData', '/supplementalData/telephoneCodeData/codesByTerritory', 'territory');
1329 foreach ($_temp2 as $key => $found) {
1330 $_temp +
= self
::_getFile('telephoneCodeData', '/supplementalData/telephoneCodeData/codesByTerritory[@territory=\'' . $key . '\']/telephoneCountryCode', 'code', $key);
1333 foreach($_temp as $key => $found) {
1334 $_temp3 = explode(" ", $found);
1335 foreach($_temp3 as $found3) {
1336 if ($found3 !== $value) {
1339 if (!isset($temp[$found3])) {
1340 $temp[$found3] = (string) $key;
1342 $temp[$found3] .= " " . $key;
1348 case 'numerictoterritory':
1349 $temp = self
::_getFile('supplementalData', '/supplementalData/codeMappings/territoryCodes[@type=\''.$value.'\']', 'numeric', $value);
1352 case 'territorytonumeric':
1353 $temp = self
::_getFile('supplementalData', '/supplementalData/codeMappings/territoryCodes[@numeric=\''.$value.'\']', 'type', $value);
1356 case 'alpha3toterritory':
1357 $temp = self
::_getFile('supplementalData', '/supplementalData/codeMappings/territoryCodes[@type=\''.$value.'\']', 'alpha3', $value);
1360 case 'territorytoalpha3':
1361 $temp = self
::_getFile('supplementalData', '/supplementalData/codeMappings/territoryCodes[@alpha3=\''.$value.'\']', 'type', $value);
1364 case 'postaltoterritory':
1365 $temp = self
::_getFile('postalCodeData', '/supplementalData/postalCodeData/postCodeRegex[@territoryId=\'' . $value . '\']', 'territoryId');
1368 case 'numberingsystem':
1369 $temp = self
::_getFile('numberingSystems', '/supplementalData/numberingSystems/numberingSystem[@id=\'' . strtolower($value) . '\']', 'digits', $value);
1372 case 'chartofallback':
1373 $_temp = self
::_getFile('characters', '/supplementalData/characters/character-fallback/character', 'value');
1374 foreach ($_temp as $key => $keyvalue) {
1375 $temp2 = self
::_getFile('characters', '/supplementalData/characters/character-fallback/character[@value=\'' . $key . '\']/substitute', '', $key);
1376 if (current($temp2) == $value) {
1382 $temp = self
::_getFile('characters', '/supplementalData/characters/character-fallback/character[@value=\'' . $value . '\']/substitute', '', $value);
1385 case 'fallbacktochar':
1386 $temp = self
::_getFile('characters', '/supplementalData/characters/character-fallback/character[@value=\'' . $value . '\']/substitute', '');
1389 case 'localeupgrade':
1390 $temp = self
::_getFile('likelySubtags', '/supplementalData/likelySubtags/likelySubtag[@from=\'' . $value . '\']', 'to', $value);
1394 $temp = self
::_getFile($locale, '/ldml/units/unit[@type=\'' . $value[0] . '\']/unitPattern[@count=\'' . $value[1] . '\']', '');
1398 require_once 'Zend/Locale/Exception.php';
1399 throw new Zend_Locale_Exception("Unknown detail ($path) for parsing locale data.");
1403 if (is_array($temp)) {
1404 $temp = current($temp);
1406 if (isset(self
::$_cache)) {
1407 self
::$_cache->save( serialize($temp), $id);
1414 * Returns the set cache
1416 * @return Zend_Cache_Core The set cache
1418 public static function getCache()
1420 return self
::$_cache;
1424 * Set a cache for Zend_Locale_Data
1426 * @param Zend_Cache_Core $cache A cache frontend
1428 public static function setCache(Zend_Cache_Core
$cache)
1430 self
::$_cache = $cache;
1434 * Returns true when a cache is set
1438 public static function hasCache()
1440 if (self
::$_cache !== null) {
1448 * Removes any set cache
1452 public static function removeCache()
1454 self
::$_cache = null;
1458 * Clears all set cache data
1462 public static function clearCache()
1464 self
::$_cache->clean();
1468 * Disables the cache
1470 * @param unknown_type $flag
1472 public static function disableCache($flag)
1474 self
::$_cacheDisabled = (boolean
) $flag;