summaryrefslogtreecommitdiff
path: root/framework/I18N
diff options
context:
space:
mode:
authorwei <>2006-01-06 05:16:25 +0000
committerwei <>2006-01-06 05:16:25 +0000
commited3e43d30524a76969fb7d42cb5e613c2e1a1d9a (patch)
tree7f0cd531766635363527715fd4614eb56df0a80c /framework/I18N
parent4835704a04cf5aa5ec71a8aef902d54b9c6cae82 (diff)
Changing property scopes in TGlobalization
Diffstat (limited to 'framework/I18N')
-rw-r--r--framework/I18N/TDateFormat.php4
-rw-r--r--framework/I18N/TGlobalization.php47
-rw-r--r--framework/I18N/TGlobalizationAutoDetect.php2
-rw-r--r--framework/I18N/TI18NControl.php2
-rw-r--r--framework/I18N/TNumberFormat.php4
-rw-r--r--framework/I18N/Translation.php8
6 files changed, 48 insertions, 19 deletions
diff --git a/framework/I18N/TDateFormat.php b/framework/I18N/TDateFormat.php
index 1226fd6f..985f5115 100644
--- a/framework/I18N/TDateFormat.php
+++ b/framework/I18N/TDateFormat.php
@@ -174,12 +174,12 @@ class TDateFormat extends TI18NControl
//initialized the default class wide formatter
if(is_null(self::$formatter))
- self::$formatter = new DateFormat($app->Culture);
+ self::$formatter = new DateFormat($app->getCulture());
$culture = $this->getCulture();
//return the specific cultural formatted date time
- if(strlen($culture) && $app->Culture !== $culture)
+ if(strlen($culture) && $app->getCulture() !== $culture)
{
$formatter = new DateFormat($culture);
return $formatter->format($this->getValue(),
diff --git a/framework/I18N/TGlobalization.php b/framework/I18N/TGlobalization.php
index 473fe315..4e6d030c 100644
--- a/framework/I18N/TGlobalization.php
+++ b/framework/I18N/TGlobalization.php
@@ -54,19 +54,19 @@ class TGlobalization extends TModule
* The current charset.
* @var string
*/
- public $Charset='UTF-8';
+ protected $_charset='UTF-8';
/**
* The current culture.
* @var string
*/
- public $Culture='en';
+ protected $_culture='en';
/**
* The content type for the http header
* @var string
*/
- public $ContentType='text/html';
+ protected $_contentType='text/html';
/**
* Initialize the Culture and Charset for this application.
@@ -76,17 +76,46 @@ class TGlobalization extends TModule
* @param TXmlElement application configuration
*/
public function init($xml)
- {
- $this->Culture = str_replace('-','_',$this->Culture);
- $this->_defaultContentType = $this->ContentType;
- $this->_defaultCharset = $this->Charset;
- $this->_defaultCulture = $this->Culture;
+ {
+ $this->_defaultContentType = $this->getContentType();
+ $this->_defaultCharset = $this->getCharset();
+ $this->_defaultCulture = $this->getCulture();
$config = $xml->getElementByTagName('translation')->getAttributes();
$this->setTranslationConfiguration($config);
$this->getApplication()->setGlobalization($this);
}
+ public function getCulture()
+ {
+ return $this->_culture;
+ }
+
+ public function setCulture($culture)
+ {
+ $this->_culture = str_replace('-','_',$culture);
+ }
+
+ public function getCharset()
+ {
+ return $this->_charset;
+ }
+
+ public function setCharset($charset)
+ {
+ $this->_charset = $charset;
+ }
+
+ public function setContentType($type)
+ {
+ $this->_contentType = $type;
+ }
+
+ public function getContentType()
+ {
+ return $this->_contentType;
+ }
+
/**
* @return TMap translation source configuration.
*/
@@ -153,7 +182,7 @@ class TGlobalization extends TModule
*/
public function getCultureVariants($culture=null)
{
- if(is_null($culture)) $culture = $this->Culture;
+ if(is_null($culture)) $culture = $this->getCulture();
$variants = explode('_', $culture);
$result = array();
for(; count($variants) > 0; array_pop($variants))
diff --git a/framework/I18N/TGlobalizationAutoDetect.php b/framework/I18N/TGlobalizationAutoDetect.php
index 6cf17bcb..3d550a62 100644
--- a/framework/I18N/TGlobalizationAutoDetect.php
+++ b/framework/I18N/TGlobalizationAutoDetect.php
@@ -21,7 +21,7 @@ class TGlobalizationAutoDetect extends TGlobalization
$http = new HTTPNegotiator();
$languages = $http->getLanguages();
if(count($languages) > 0)
- $this->Culture = $languages[0];
+ $this->setCulture($languages[0]);
}
}
diff --git a/framework/I18N/TI18NControl.php b/framework/I18N/TI18NControl.php
index 01df1332..44e15f2f 100644
--- a/framework/I18N/TI18NControl.php
+++ b/framework/I18N/TI18NControl.php
@@ -81,7 +81,7 @@ class TI18NControl extends TControl
//fall back to globalization charset
if(empty($charset))
- $charset = is_null($app) ? '' : $app->Charset;
+ $charset = is_null($app) ? '' : $app->getCharset();
//fall back to default charset
if(empty($charset))
diff --git a/framework/I18N/TNumberFormat.php b/framework/I18N/TNumberFormat.php
index 712f548b..9f2de233 100644
--- a/framework/I18N/TNumberFormat.php
+++ b/framework/I18N/TNumberFormat.php
@@ -179,14 +179,14 @@ class TNumberFormat extends TI18NControl
$app = $this->Application->getGlobalization();
//initialized the default class wide formatter
if(is_null(self::$formatter))
- self::$formatter = new NumberFormat($app->Culture);
+ self::$formatter = new NumberFormat($app->getCulture());
$pattern = strlen($this->getPattern()) > 0
? $this->getPattern() : $this->getType();
$culture = $this->getCulture();
//return the specific cultural formatted number
- if(!empty($culture) && $app->Culture != $culture)
+ if(!empty($culture) && $app->getCulture() != $culture)
{
$formatter = new NumberFormat($culture);
return $formatter->format($this->getValue(),$pattern,
diff --git a/framework/I18N/Translation.php b/framework/I18N/Translation.php
index 8b420bbf..8f45ff64 100644
--- a/framework/I18N/Translation.php
+++ b/framework/I18N/Translation.php
@@ -56,12 +56,12 @@ class Translation extends TComponent
$config['source'],
$config['filename']);
- $source->setCulture($app->Culture);
+ $source->setCulture($app->getCulture());
if($config['cache'])
$source->setCache(new MessageCache($config['cache']));
- self::$formatter = new MessageFormat($source, $app->Charset);
+ self::$formatter = new MessageFormat($source, $app->getCharset());
//save the message on end request
Prado::getApplication()->attachEventHandler(
@@ -92,7 +92,7 @@ class Translation extends TComponent
$config = $app->getTranslationConfiguration();
if(isset($config['autosave']))
{
- $formatter->getSource()->setCulture($app->Culture);
+ $formatter->getSource()->setCulture($app->getCulture());
$formatter->getSource()->save($config['catalogue']);
}
$onceonly = false;
@@ -129,7 +129,7 @@ function localize($text, $parameters=array(), $catalogue=null, $charset=null)
$catalogue = $config['catalogue'];
//globalization charset
- $appCharset = is_null($app) ? '' : $app->Charset;
+ $appCharset = is_null($app) ? '' : $app->getCharset();
//default charset
$defaultCharset = (is_null($app)) ? 'UTF-8' : $app->getDefaultCharset();