From 90b3f22cba8ad85ef2eb38c158fa2da46d798cf8 Mon Sep 17 00:00:00 2001 From: xue <> Date: Fri, 8 Sep 2006 19:31:03 +0000 Subject: merge from 3.0 branch till 1397. --- framework/I18N/TChoiceFormat.php | 2 +- framework/I18N/TDateFormat.php | 2 +- framework/I18N/TGlobalization.php | 2 +- framework/I18N/TI18NControl.php | 2 +- framework/I18N/TNumberFormat.php | 2 +- framework/I18N/TTranslate.php | 2 +- framework/I18N/TTranslateParameter.php | 2 +- framework/I18N/Translation.php | 2 +- framework/I18N/core/CultureInfo.php | 212 +++++++++++++++---------------- framework/I18N/core/Gettext/MO.php | 2 +- framework/I18N/core/Gettext/PO.php | 2 +- framework/I18N/core/Gettext/TGettext.php | 2 +- framework/I18N/core/MessageCache.php | 4 +- framework/I18N/core/TCache_Lite.php | 2 +- 14 files changed, 120 insertions(+), 120 deletions(-) (limited to 'framework/I18N') diff --git a/framework/I18N/TChoiceFormat.php b/framework/I18N/TChoiceFormat.php index cd6ef511..bf646c31 100644 --- a/framework/I18N/TChoiceFormat.php +++ b/framework/I18N/TChoiceFormat.php @@ -6,7 +6,7 @@ * @link http://www.pradosoft.com/ * @copyright Copyright © 2005 PradoSoft * @license http://www.pradosoft.com/license/ - * @version $Revision: $ $Date: $ + * @version $Id$ * @package System.I18N */ diff --git a/framework/I18N/TDateFormat.php b/framework/I18N/TDateFormat.php index 0f5507ab..1f27cefe 100644 --- a/framework/I18N/TDateFormat.php +++ b/framework/I18N/TDateFormat.php @@ -6,7 +6,7 @@ * @link http://www.pradosoft.com/ * @copyright Copyright © 2005 PradoSoft * @license http://www.pradosoft.com/license/ - * @version $Revision: $ $Date: $ + * @version $Id$ * @package System.I18N */ diff --git a/framework/I18N/TGlobalization.php b/framework/I18N/TGlobalization.php index 1ea7ce2b..d3c6d233 100644 --- a/framework/I18N/TGlobalization.php +++ b/framework/I18N/TGlobalization.php @@ -6,7 +6,7 @@ * @link http://www.pradosoft.com/ * @copyright Copyright © 2005 PradoSoft * @license http://www.pradosoft.com/license/ - * @version $Revision: $ $Date: $ + * @version $Id$ * @package System.I18N */ diff --git a/framework/I18N/TI18NControl.php b/framework/I18N/TI18NControl.php index efe3ac84..7ca0e6b2 100644 --- a/framework/I18N/TI18NControl.php +++ b/framework/I18N/TI18NControl.php @@ -6,7 +6,7 @@ * @link http://www.pradosoft.com/ * @copyright Copyright © 2005 PradoSoft * @license http://www.pradosoft.com/license/ - * @version $Revision: $ $Date: $ + * @version $Id$ * @package System.I18N */ diff --git a/framework/I18N/TNumberFormat.php b/framework/I18N/TNumberFormat.php index 76373a8e..5f16873e 100644 --- a/framework/I18N/TNumberFormat.php +++ b/framework/I18N/TNumberFormat.php @@ -6,7 +6,7 @@ * @link http://www.pradosoft.com/ * @copyright Copyright © 2005 PradoSoft * @license http://www.pradosoft.com/license/ - * @version $Revision: $ $Date: $ + * @version $Id$ * @package System.I18N */ diff --git a/framework/I18N/TTranslate.php b/framework/I18N/TTranslate.php index da5876d4..e1f2fee5 100644 --- a/framework/I18N/TTranslate.php +++ b/framework/I18N/TTranslate.php @@ -6,7 +6,7 @@ * @link http://www.pradosoft.com/ * @copyright Copyright © 2005 PradoSoft * @license http://www.pradosoft.com/license/ - * @version $Revision: $ $Date: $ + * @version $Id$ * @package System.I18N */ diff --git a/framework/I18N/TTranslateParameter.php b/framework/I18N/TTranslateParameter.php index 3f9f72ac..7ead6e87 100644 --- a/framework/I18N/TTranslateParameter.php +++ b/framework/I18N/TTranslateParameter.php @@ -6,7 +6,7 @@ * @link http://www.pradosoft.com/ * @copyright Copyright © 2005 PradoSoft * @license http://www.pradosoft.com/license/ - * @version $Revision: $ $Date: $ + * @version $Id$ * @package System.I18N */ diff --git a/framework/I18N/Translation.php b/framework/I18N/Translation.php index 960ff1f9..33696304 100644 --- a/framework/I18N/Translation.php +++ b/framework/I18N/Translation.php @@ -6,7 +6,7 @@ * @link http://www.pradosoft.com/ * @copyright Copyright © 2005 PradoSoft * @license http://www.pradosoft.com/license/ - * @version $Revision: $ $Date: $ + * @version $Id$ * @package System.I18N */ diff --git a/framework/I18N/core/CultureInfo.php b/framework/I18N/core/CultureInfo.php index 299a8b16..bcf2f245 100644 --- a/framework/I18N/core/CultureInfo.php +++ b/framework/I18N/core/CultureInfo.php @@ -13,117 +13,117 @@ * {@link http://prado.sourceforge.net/} * * @author Wei Zhuo - * @version $Revision: 1.6 $ $Date: 2005/12/16 05:26:17 $ + * @version $Id$ * @package System.I18N.core */ - + /** * CultureInfo class. - * - * Represents information about a specific culture including the - * names of the culture, the calendar used, as well as access to - * culture-specific objects that provide methods for common operations, + * + * Represents information about a specific culture including the + * names of the culture, the calendar used, as well as access to + * culture-specific objects that provide methods for common operations, * such as formatting dates, numbers, and currency. - * - * The CultureInfo class holds culture-specific information, such as the - * associated language, sublanguage, country/region, calendar, and cultural - * conventions. This class also provides access to culture-specific + * + * The CultureInfo class holds culture-specific information, such as the + * associated language, sublanguage, country/region, calendar, and cultural + * conventions. This class also provides access to culture-specific * instances of DateTimeFormatInfo and NumberFormatInfo. These objects * contain the information required for culture-specific operations, * such as formatting dates, numbers and currency. - * - * The culture names follow the format "_", + * + * The culture names follow the format "_", * where is a lowercase two-letter code derived from ISO 639 - * codes. You can find a full list of the ISO-639 codes at - * http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt - * - * The is an uppercase two-letter code derived from - * ISO 3166. A copy of ISO-3166 can be found at + * codes. You can find a full list of the ISO-639 codes at + * http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt + * + * The is an uppercase two-letter code derived from + * ISO 3166. A copy of ISO-3166 can be found at * http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html * - * For example, Australian English is "en_AU". - * + * For example, Australian English is "en_AU". + * * @author Xiang Wei Zhuo - * @version v1.0, last update on Sat Dec 04 13:41:46 EST 2004 + * @version $Id$ * @package System.I18N.core */ class CultureInfo { /** * ICU data filename extension. - * @var string + * @var string */ private $dataFileExt = '.dat'; /** * The ICU data array. - * @var array + * @var array */ private $data = array(); /** * The current culture. - * @var string + * @var string */ private $culture; /** * Directory where the ICU data is stored. - * @var string + * @var string */ private $dataDir; /** * A list of ICU date files loaded. - * @var array + * @var array */ private $dataFiles = array(); /** * The current date time format info. - * @var DateTimeFormatInfo + * @var DateTimeFormatInfo */ private $dateTimeFormat; /** * The current number format info. - * @var NumberFormatInfo + * @var NumberFormatInfo */ private $numberFormat; - + /** * A list of properties that are accessable/writable. - * @var array - */ + * @var array + */ protected $properties = array(); /** - * Culture type, all. + * Culture type, all. * @see getCultures() - * @var int + * @var int */ const ALL = 0; /** - * Culture type, neutral. + * Culture type, neutral. * @see getCultures() - * @var int - */ + * @var int + */ const NEUTRAL = 1; - + /** - * Culture type, specific. + * Culture type, specific. * @see getCultures() - * @var int - */ + * @var int + */ const SPECIFIC = 2; /** - * Display the culture name. + * Display the culture name. * @return string the culture name. * @see getName() */ - function __toString() + function __toString() { return $this->getName(); } @@ -134,7 +134,7 @@ class CultureInfo * as an attribute/property to retrieve the value. * @return mixed */ - function __get($name) + function __get($name) { $getProperty = 'get'.$name; if(in_array($getProperty, $this->properties)) @@ -142,33 +142,33 @@ class CultureInfo else throw new Exception('Property '.$name.' does not exists.'); } - + /** * Allow functions that begins with 'set' to be called directly * as an attribute/property to set the value. */ - function __set($name, $value) + function __set($name, $value) { $setProperty = 'set'.$name; if(in_array($setProperty, $this->properties)) $this->$setProperty($value); else throw new Exception('Property '.$name.' can not be set.'); - } + } + - /** - * Initializes a new instance of the CultureInfo class based on the + * Initializes a new instance of the CultureInfo class based on the * culture specified by name. E.g. new CultureInfo('en_AU'); - * The culture indentifier must be of the form + * The culture indentifier must be of the form * "language_(country/region/variant)". * @param string a culture name, e.g. "en_AU". * @return return new CultureInfo. */ - function __construct($culture='en') + function __construct($culture='en') { - $this->properties = get_class_methods($this); - + $this->properties = get_class_methods($this); + if(empty($culture)) $culture = 'en'; @@ -176,41 +176,41 @@ class CultureInfo $this->dataFileExt = $this->fileExt(); $this->setCulture($culture); - + $this->loadCultureData('root'); - $this->loadCultureData($culture); + $this->loadCultureData($culture); } - + /** * Get the default directory for the ICU data. * The default is the "data" directory for this class. - * @return string directory containing the ICU data. + * @return string directory containing the ICU data. */ protected static function dataDir() { return dirname(__FILE__).'/data/'; } - + /** * Get the filename extension for ICU data. Default is ".dat". - * @return string filename extension for ICU data. + * @return string filename extension for ICU data. */ protected static function fileExt() { return '.dat'; } - + /** * Determine if a given culture is valid. Simply checks that the * culture data exists. * @param string a culture - * @return boolean true if valid, false otherwise. + * @return boolean true if valid, false otherwise. */ public function validCulture($culture) { if(preg_match('/^[a-z]{2}(_[A-Z]{2,5}){0,2}$/', $culture)) return is_file(self::dataDir().$culture.self::fileExt()); - + return false; } @@ -235,10 +235,10 @@ class CultureInfo * @param string the culture identifier. */ protected function loadCultureData($culture) - { + { $file_parts = explode('_',$culture); $current_part = $file_parts[0]; - + $files = array($current_part); for($i = 1, $k = count($file_parts); $i < $k; ++$i) @@ -257,29 +257,29 @@ class CultureInfo if(in_array($filename, $this->dataFiles) === false) { array_unshift($this->dataFiles, $file); - + $data = &$this->getData($filename); $this->data[$file] = &$data; - + if(isset($data['__ALIAS'])) $this->loadCultureData($data['__ALIAS'][0]); unset($data); } - } + } } - + /** * Get the data by unserializing the ICU data from disk. * The data files are cached in a static variable inside * this function. * @param string the ICU data filename - * @return array ICU data + * @return array ICU data */ protected function &getData($filename) { static $data = array(); static $files = array(); - + if(!in_array($filename, $files)) { $data[$filename] = unserialize(file_get_contents($filename)); @@ -288,7 +288,7 @@ class CultureInfo return $data[$filename]; } - + /** * Find the specific ICU data information from the data. * The path to the specific ICU data is separated with a slash "/". @@ -297,19 +297,19 @@ class CultureInfo * Use merge=true to return the ICU including the parent culture. * E.g. The currency data for a variant, say "en_AU" contains one * entry, the currency for AUD, the other currency data are stored - * in the "en" data file. Thus to retrieve all the data regarding + * in the "en" data file. Thus to retrieve all the data regarding * currency for "en_AU", you need to use findInfo("Currencies,true);. * @param string the data you want to find. * @param boolean merge the data from its parents. - * @return mixed the specific ICU data. + * @return mixed the specific ICU data. */ - protected function findInfo($path='/', $merge=false) + protected function findInfo($path='/', $merge=false) { $result = array(); foreach($this->dataFiles as $section) - { + { $info = $this->searchArray($this->data[$section], $path); - + if($info) { if($merge) @@ -321,7 +321,7 @@ class CultureInfo return $result; } - + /** * Search the array for a specific value using a path separated using * slash "/" separated path. e.g to find $info['hello']['world'], @@ -330,7 +330,7 @@ class CultureInfo * @param string slash "/" separated array path. * @return mixed the value array using the path */ - private function searchArray($info, $path='/') + private function searchArray($info, $path='/') { $index = explode('/',$path); @@ -345,11 +345,11 @@ class CultureInfo return $array[$value]; } } - + /** - * Gets the culture name in the format + * Gets the culture name in the format * "_(country/regioncode2)". - * @return string culture name. + * @return string culture name. */ function getName() { @@ -359,9 +359,9 @@ class CultureInfo /** * Gets the DateTimeFormatInfo that defines the culturally appropriate * format of displaying dates and times. - * @return DateTimeFormatInfo date time format information for the culture. + * @return DateTimeFormatInfo date time format information for the culture. */ - function getDateTimeFormat() + function getDateTimeFormat() { if(is_null($this->dateTimeFormat)) { @@ -377,7 +377,7 @@ class CultureInfo * Set the date time format information. * @param DateTimeFormatInfo the new date time format info. */ - function setDateTimeFormat($dateTimeFormat) + function setDateTimeFormat($dateTimeFormat) { $this->dateTimeFormat = $dateTimeFormat; } @@ -386,7 +386,7 @@ class CultureInfo * Gets the default calendar used by the culture, e.g. "gregorian". * @return string the default calendar. */ - function getCalendar() + function getCalendar() { $info = $this->findInfo('calendar/default'); return $info[0]; @@ -414,7 +414,7 @@ class CultureInfo * Gets the culture name in English. * Returns array('Language','Country'); * 'Country' is omitted if the culture is neutral. - * @return array array with language and country as elements. + * @return array array with language and country as elements. */ function getEnglishName() { @@ -427,7 +427,7 @@ class CultureInfo if($region) return $language[0].' ('.$region[0].')'; else - return $language[0]; + return $language[0]; } /** @@ -435,7 +435,7 @@ class CultureInfo * Any changes to the invariant culture affects all other * instances of the invariant culture. * The invariant culture is assumed to be "en"; - * @return CultureInfo invariant culture info is "en". + * @return CultureInfo invariant culture info is "en". */ static function getInvariantCulture() { @@ -446,10 +446,10 @@ class CultureInfo } /** - * Gets a value indicating whether the current CultureInfo + * Gets a value indicating whether the current CultureInfo * represents a neutral culture. Returns true if the culture * only contains two characters. - * @return boolean true if culture is neutral, false otherwise. + * @return boolean true if culture is neutral, false otherwise. */ function getIsNeutralCulture() { @@ -459,7 +459,7 @@ class CultureInfo /** * Gets the NumberFormatInfo that defines the culturally appropriate * format of displaying numbers, currency, and percentage. - * @return NumberFormatInfo the number format info for current culture. + * @return NumberFormatInfo the number format info for current culture. */ function getNumberFormat() { @@ -471,7 +471,7 @@ class CultureInfo $data = array( 'NumberElements'=>$elements, 'NumberPatterns'=>$patterns, 'Currencies' => $currencies); - + $this->setNumberFormat(new NumberFormatInfo($data)); } return $this->numberFormat; @@ -487,9 +487,9 @@ class CultureInfo } /** - * Gets the CultureInfo that represents the parent culture of the + * Gets the CultureInfo that represents the parent culture of the * current CultureInfo - * @return CultureInfo parent culture information. + * @return CultureInfo parent culture information. */ function getParent() { @@ -501,26 +501,26 @@ class CultureInfo } /** - * Gets the list of supported cultures filtered by the specified + * Gets the list of supported cultures filtered by the specified * culture type. This is an EXPENSIVE function, it needs to traverse * a list of ICU files in the data directory. * This function can be called statically. * @param int culture type, CultureInfo::ALL, CultureInfo::NEUTRAL * or CultureInfo::SPECIFIC. - * @return array list of culture information available. + * @return array list of culture information available. */ static function getCultures($type=CultureInfo::ALL) { $dataDir = CultureInfo::dataDir(); $dataExt = CultureInfo::fileExt(); $dir = dir($dataDir); - + $neutral = array(); $specific = array(); - while (false !== ($entry = $dir->read())) + while (false !== ($entry = $dir->read())) { - if(is_file($dataDir.$entry) + if(is_file($dataDir.$entry) && substr($entry,-4) == $dataExt && $entry != 'root'.$dataExt) { @@ -545,7 +545,7 @@ class CultureInfo break; case CultureInfo::SPECIFIC : return $specific; - break; + break; } } @@ -554,7 +554,7 @@ class CultureInfo * E.g. array(0 => array('hello'), 1 => 'world'); * becomes array(0 => 'hello', 1 => 'world'); * @param array with single elements arrays - * @return array simplified array. + * @return array simplified array. */ private function simplify($array) { @@ -571,7 +571,7 @@ class CultureInfo /** * Get a list of countries in the language of the localized version. - * @return array a list of localized country names. + * @return array a list of localized country names. */ function getCountries() { @@ -580,7 +580,7 @@ class CultureInfo /** * Get a list of currencies in the language of the localized version. - * @return array a list of localized currencies. + * @return array a list of localized currencies. */ function getCurrencies() { @@ -589,7 +589,7 @@ class CultureInfo /** * Get a list of languages in the language of the localized version. - * @return array list of localized language names. + * @return array list of localized language names. */ function getLanguages() { @@ -598,8 +598,8 @@ class CultureInfo /** * Get a list of scripts in the language of the localized version. - * @return array list of localized script names. - */ + * @return array list of localized script names. + */ function getScripts() { return $this->simplify($this->findInfo('Scripts',true)); @@ -607,8 +607,8 @@ class CultureInfo /** * Get a list of timezones in the language of the localized version. - * @return array list of localized timezones. - */ + * @return array list of localized timezones. + */ function getTimeZones() { return $this->simplify($this->findInfo('zoneStrings',true)); diff --git a/framework/I18N/core/Gettext/MO.php b/framework/I18N/core/Gettext/MO.php index 9f2d5799..b4899949 100644 --- a/framework/I18N/core/Gettext/MO.php +++ b/framework/I18N/core/Gettext/MO.php @@ -29,7 +29,7 @@ // | Copyright (c) 2004 Michael Wallner | // +----------------------------------------------------------------------+ // -// $Id: MO.php,v 1.3 2005/08/27 03:21:12 weizhuo Exp $ +// $Id$ /** * File::Gettext::MO diff --git a/framework/I18N/core/Gettext/PO.php b/framework/I18N/core/Gettext/PO.php index 3a5fda04..7df99496 100644 --- a/framework/I18N/core/Gettext/PO.php +++ b/framework/I18N/core/Gettext/PO.php @@ -28,7 +28,7 @@ // | Copyright (c) 2004 Michael Wallner | // +----------------------------------------------------------------------+ // -// $Id: PO.php,v 1.2 2005/01/05 03:15:14 weizhuo Exp $ +// $Id$ /** * File::Gettext::PO diff --git a/framework/I18N/core/Gettext/TGettext.php b/framework/I18N/core/Gettext/TGettext.php index c13940b3..5dc0ae02 100644 --- a/framework/I18N/core/Gettext/TGettext.php +++ b/framework/I18N/core/Gettext/TGettext.php @@ -28,7 +28,7 @@ // | Copyright (c) 2004 Michael Wallner | // +----------------------------------------------------------------------+ // -// $Id: TGettext.php,v 1.4 2005/01/09 23:36:23 qiangxue Exp $ +// $Id$ /** * File::Gettext diff --git a/framework/I18N/core/MessageCache.php b/framework/I18N/core/MessageCache.php index e39ff63a..08757730 100644 --- a/framework/I18N/core/MessageCache.php +++ b/framework/I18N/core/MessageCache.php @@ -2,7 +2,7 @@ /** * Translation table cache. * @author $Author: weizhuo $ - * @version $Id: MessageCache.php,v 1.3 2005/01/05 03:15:14 weizhuo Exp $ + * @version $Id$ * @package System.I18N.core */ @@ -16,7 +16,7 @@ require_once(dirname(__FILE__).'/TCache_Lite.php'); * It can cache each cataloug+variant or just the whole section. * @package System.I18N.core * @author $Author: weizhuo $ - * @version $Id: MessageCache.php,v 1.3 2005/01/05 03:15:14 weizhuo Exp $ + * @version $Id$ */ class MessageCache { diff --git a/framework/I18N/core/TCache_Lite.php b/framework/I18N/core/TCache_Lite.php index 260e56c4..5eb9825d 100644 --- a/framework/I18N/core/TCache_Lite.php +++ b/framework/I18N/core/TCache_Lite.php @@ -38,7 +38,7 @@ * Mike BENOIT * * @package System.I18N.core -* @version $Id: TCache_Lite.php,v 1.3 2005/10/09 10:24:12 weizhuo Exp $ +* @version $Id$ * @author Fabien MARTY * @copyright 1997-2005 The PHP Group * @license http://www.gnu.org/copyleft/lesser.html GNU LGPL -- cgit v1.2.3