summaryrefslogtreecommitdiff
path: root/framework/I18N/TTranslate.php
diff options
context:
space:
mode:
Diffstat (limited to 'framework/I18N/TTranslate.php')
-rw-r--r--framework/I18N/TTranslate.php64
1 files changed, 31 insertions, 33 deletions
diff --git a/framework/I18N/TTranslate.php b/framework/I18N/TTranslate.php
index ac708191..d38e3281 100644
--- a/framework/I18N/TTranslate.php
+++ b/framework/I18N/TTranslate.php
@@ -2,11 +2,11 @@
/**
* TTranslate, I18N translation component.
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the BSD License.
*
- * Copyright(c) 2004 by Xiang Wei Zhuo.
+ * Copyright(c) 2004 by Xiang Wei Zhuo.
*
* To contact the author write to {@link mailto:qiang.xue@gmail.com Qiang Xue}
* The latest version of PRADO can be obtained from:
@@ -17,11 +17,9 @@
* @package System.I18N
*/
- Prado::using('System.IO.TTextWriter');
-
/**
* TTranslate class.
- *
+ *
* This component performs message/string translation. The translation
* source is set in the TGlobalization handler. The following example
* demonstrated a simple message translation.
@@ -32,9 +30,9 @@
* Depending on the culture set on the page, the phrase "Goodbye" will
* be translated.
*
- * The values of any attribute in TTranslate are consider as values for
- * substitution. Strings enclosed with "{" and "}" are consider as the
- * parameters. The following example will substitution the string
+ * The values of any attribute in TTranslate are consider as values for
+ * substitution. Strings enclosed with "{" and "}" are consider as the
+ * parameters. The following example will substitution the string
* "{time}" with the value of the attribute "time="#time()". Note that
* the value of the attribute time is evaluated.
* <code>
@@ -44,17 +42,17 @@
* </code>
*
* More complex string substitution can be applied using the
- * TParam component.
+ * TParam component.
*
* Namespace: System.I18N
*
* Properties
- * - <b>Text</b>, string,
- * <br>Gets or sets the string to translate.
+ * - <b>Text</b>, string,
+ * <br>Gets or sets the string to translate.
* - <b>Catalogue</b>, string,
* <br>Gets or sets the catalogue for message translation. The
* default catalogue can be set by the @Page directive.
- * - <b>Key</b>, string,
+ * - <b>Key</b>, string,
* <br>Gets or sets the key used to message look up.
* - <b>Trim</b>, boolean,
* <br>Gets or sets an option to trim the contents.
@@ -65,7 +63,7 @@
* @package System.I18N
*/
class TTranslate extends TI18NControl
-{
+{
/**
* @return string the text to be localized/translated.
*/
@@ -91,52 +89,52 @@ class TTranslate extends TI18NControl
{
$this->setViewState('Key',$value,'');
}
-
+
/**
* Get the key for message lookup.
* @return string key
- */
+ */
function getKey()
{
return $this->getViewState('Key','');
}
-
+
/**
* Get the message catalogue.
- * @return string catalogue.
+ * @return string catalogue.
*/
function getCatalogue()
{
return $this->getViewState('Catalogue','');
}
-
+
/**
* Set the message catalogue.
- * @param string catalogue.
- */
+ * @param string catalogue.
+ */
function setCatalogue($value)
{
$this->setViewState('Catalogue',$value,'');
}
-
+
/**
* Set the option to trim the contents.
* @param boolean trim or not.
- */
+ */
function setTrim($value)
{
$this->setViewState('Trim',TPropertyValue::ensureBoolean($value),true);
}
-
+
/**
* Trim the content or not.
- * @return boolean trim or not.
- */
+ * @return boolean trim or not.
+ */
function getTrim()
{
return $this->getViewState('Trim',true);
}
-
+
/**
* renders the translated string.
*/
@@ -157,8 +155,8 @@ class TTranslate extends TI18NControl
$text = $this->getText();
if(strlen($text)==0)
- $text = $textWriter->flush();
- if($this->getTrim())
+ $text = $textWriter->flush();
+ if($this->getTrim())
$text = trim($text);
$writer->write($this->translateText($text, $subs));
@@ -177,20 +175,20 @@ class TTranslate extends TI18NControl
//no translation handler provided
if(is_null($config = $app->getTranslationConfiguration()))
return strtr($text, $subs);
-
+
Translation::init();
-
+
$catalogue = $this->getCatalogue();
if(empty($catalogue) && isset($config['catalogue']))
$catalogue = $config['catalogue'];
-
+
$key = $this->getKey();
if(!empty($key)) $text = $key;
-
+
//translate it
return Translation::formatter()->format($text,
$subs, $catalogue, $this->getCharset());
- }
+ }
}
?> \ No newline at end of file