From 63c79dd722d5a8dd09b8828a4711d496680c0062 Mon Sep 17 00:00:00 2001
From: xue <>
Date: Mon, 3 Apr 2006 21:55:33 +0000
Subject: Cleanup of I18N.
---
framework/I18N/TGlobalization.php | 74 ++++++++++++++++++++++++---------------
1 file changed, 46 insertions(+), 28 deletions(-)
(limited to 'framework/I18N/TGlobalization.php')
diff --git a/framework/I18N/TGlobalization.php b/framework/I18N/TGlobalization.php
index 0e664378..aa545d21 100644
--- a/framework/I18N/TGlobalization.php
+++ b/framework/I18N/TGlobalization.php
@@ -38,23 +38,24 @@ class TGlobalization extends TModule
*/
private $_defaultCulture = 'en';
- /**
- * Translation source parameters.
- * @var TMap
- */
- private $_translation;
-
/**
* The current charset.
* @var string
*/
- protected $_charset='UTF-8';
+ private $_charset=null;
/**
* The current culture.
* @var string
*/
- protected $_culture='en';
+ private $_culture=null;
+
+ /**
+ * Translation source parameters.
+ * @var TMap
+ */
+ private $_translation;
+
/**
* Initialize the Culture and Charset for this application.
@@ -65,8 +66,10 @@ class TGlobalization extends TModule
*/
public function init($xml)
{
- $this->_defaultCharset = $this->getCharset();
- $this->_defaultCulture = $this->getCulture();
+ if($this->_charset===null)
+ $this->_charset=$this->getDefaultCharset();
+ if($this->_culture===null)
+ $this->_culture=$this->getDefaultCulture();
if($xml!==null)
{
@@ -77,6 +80,38 @@ class TGlobalization extends TModule
$this->getApplication()->setGlobalization($this);
}
+ /**
+ * @return string default culture
+ */
+ public function getDefaultCulture()
+ {
+ return $this->_defaultCulture;
+ }
+
+ /**
+ * @param string default culture, e.g. en_US for American English
+ */
+ public function setDefaultCulture($culture)
+ {
+ $this->_defaultCharset = str_replace('-','_',$culture);
+ }
+
+ /**
+ * @return string default charset set
+ */
+ public function getDefaultCharset()
+ {
+ return $this->_defaultCharset;
+ }
+
+ /**
+ * @param string default localization charset, e.g. UTF-8
+ */
+ public function setDefaultCharset($charset)
+ {
+ $this->_defaultCharset = $charset;
+ }
+
/**
* @return string current application culture
*/
@@ -128,7 +163,6 @@ class TGlobalization extends TModule
*
* Throws exception is source is not found.
* @param TMap configuration options
- * @return ${return}
*/
protected function setTranslationConfiguration(TMap $config)
{
@@ -156,23 +190,7 @@ class TGlobalization extends TModule
*/
public function setTranslationCatalogue($value)
{
- return $this->_translation['catalogue'] = $value;
- }
-
- /**
- * @return string default charset set in application.xml
- */
- public function getDefaultCharset()
- {
- return $this->_defaultCharset;
- }
-
- /**
- * @return string default culture set in application.xml
- */
- public function getDefaultCulture()
- {
- return $this->_defaultCulture;
+ $this->_translation['catalogue'] = $value;
}
/**
--
cgit v1.2.3