From 4835704a04cf5aa5ec71a8aef902d54b9c6cae82 Mon Sep 17 00:00:00 2001 From: wei <> Date: Fri, 6 Jan 2006 04:42:44 +0000 Subject: Adding I18N support. --- framework/I18N/TI18NControl.php | 94 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 framework/I18N/TI18NControl.php (limited to 'framework/I18N/TI18NControl.php') diff --git a/framework/I18N/TI18NControl.php b/framework/I18N/TI18NControl.php new file mode 100644 index 00000000..01df1332 --- /dev/null +++ b/framework/I18N/TI18NControl.php @@ -0,0 +1,94 @@ + + * @version $Revision: 1.1 $ $Date: 2005/08/27 03:21:12 $ + * @package System.I18N + */ + + +/** + * Base class for I18N components, providing Culture and Charset properties. + * Namespace: System.I18N + * + * Properties + * - Culture, string, + *
Gets or sets the culture for formatting. If the Culture property + * is not specified. The culture from the Application/Page is used. + * - Charset, string, + *
Gets or sets the charset for both input and output. + * If the Charset property is not specified. The charset from the + * Application/Page is used. The default is UTF-8. + * + * @author Xiang Wei Zhuo + * @version v1.0, last update on Sat Dec 11 15:25:11 EST 2004 + * @package System.I18N + */ +class TI18NControl extends TControl +{ + + /** + * Sets the charset for message output + * @param string the charset, e.g. UTF-8 + */ + public function setCharset($value) + { + $this->setViewState('Charset',$value,''); + } + + + /** + * Get the specific culture for this control. + * @param parameter + * @return string culture identifier. + */ + public function getCulture() + { + return $this->getViewState('Culture',''); + } + + /** + * Get the custom culture identifier. + * @param string culture identifier. + */ + public function setCulture($culture) + { + $this->setViewState('Culture',$culture,''); + } + + /** + * Gets the charset, with fall back to the application charset, + * then the default charset in globalization, and finally UTF-8 + * @return string charset + */ + public function getCharset() + { + $app = $this->Application->getGlobalization(); + + //instance charset + $charset = $this->getViewState('Charset',''); + + //fall back to globalization charset + if(empty($charset)) + $charset = is_null($app) ? '' : $app->Charset; + + //fall back to default charset + if(empty($charset)) + $charset = (is_null($app)) ? 'UTF-8' : $app->getDefaultCharset(); + + return $charset; + } +} + +?> \ No newline at end of file -- cgit v1.2.3