summaryrefslogtreecommitdiff
path: root/framework/I18N/TChoiceFormat.php
diff options
context:
space:
mode:
authorctrlaltca <>2012-07-12 11:21:01 +0000
committerctrlaltca <>2012-07-12 11:21:01 +0000
commit903ae8a581fac1e6917fc3e31d2ad8fb91df80c3 (patch)
treee08bf04f0823650a231227ac3499121270172a23 /framework/I18N/TChoiceFormat.php
parent3e4e6e66aeb3f8fea4e1eb4237498ef9d2358f63 (diff)
standardize the use of unix eol; use svn properties to enforce native eol
Diffstat (limited to 'framework/I18N/TChoiceFormat.php')
-rw-r--r--framework/I18N/TChoiceFormat.php220
1 files changed, 110 insertions, 110 deletions
diff --git a/framework/I18N/TChoiceFormat.php b/framework/I18N/TChoiceFormat.php
index a1d7ad74..401b25d9 100644
--- a/framework/I18N/TChoiceFormat.php
+++ b/framework/I18N/TChoiceFormat.php
@@ -1,111 +1,111 @@
-<?php
-/**
- * TChoiceFormat, I18N choice format component.
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @link http://www.pradosoft.com/
+<?php
+/**
+ * TChoiceFormat, I18N choice format component.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @link http://www.pradosoft.com/
* @copyright Copyright &copy; 2005-2012 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- * @package System.I18N
- */
-
- /**
- * Get the ChoiceFormat class.
- */
-Prado::using('System.I18N.core.ChoiceFormat');
-Prado::using('System.I18N.TTranslate');
-
-/**
- * TChoiceFormat class.
- *
- * This component performs message/string choice translation. The translation
- * source is set in the TGlobalization module. The following example
- * demonstrates a simple 2 choice message translation.
- * <code>
- * <com:TChoiceFormat Value="1">[1] One Apple. |[2] Two Apples</com:TChoiceFormat>
- * </code>
- *
- * The Choice has <b>Value</b> "1" (one), thus the translated string
- * is "One Apple". If the <b>Value</b> is "2", then it will show
- * "Two Apples".
- *
- * The message/string choices are separated by the pipe "|" followed
- * by a set notation of the form
- * # <tt>[1,2]</tt> -- accepts values between 1 and 2, inclusive.
- * # <tt>(1,2)</tt> -- accepts values between 1 and 2, excluding 1 and 2.
- * # <tt>{1,2,3,4}</tt> -- only values defined in the set are accepted.
- * # <tt>[-Inf,0)</tt> -- accepts value greater or equal to negative infinity
- * and strictly less than 0
- * Any non-empty combinations of the delimiters of square and round brackets
- * are acceptable.
- *
- * The string choosen for display depends on the <b>Value</b> property.
- * The <b>Value</b> is evaluated for each set until the Value is found
- * to belong to a particular set.
- *
- * Properties
- * - <b>Value</b>, float,
- * <br>Gets or sets the Value that determines which string choice to display.
- * Since version 3.1.2 the following set notation is also possible.
- *
- * # <tt>{n: n % 10 > 1 && n % 10 < 5}</tt> -- matches numbers like 2, 3, 4, 22, 23, 24
- *
- * Where set is defined by the expression after <tt>n:</tt>. In particular, the expression
- * accepts the following mathematical/logical operators to form a set of logical conditions
- * on the value given by <tt>n</tt>:
- * # <tt>&lt;</tt> -- less than.
- * # <tt>&lt;=</tt> -- less than equals.
- * # <tt>&gt;</tt> -- greater than.
- * # <tt>&gt=</tt> -- greater than equals.
- * # <tt>==</tt> -- of equal value.
- * # <tt>%</tt> -- modulo, e.g., 1 % 10 equals 1, 11 % 10 equals 1.
- * # <tt>-</tt> -- minus, negative.
- * # <tt>+</tt> -- addition.
- * # <tt>&amp;</tt> -- conditional AND.
- * # <tt>&amp;&amp;</tt> -- condition AND with short circuit.
- * # <tt>|</tt> -- conditional OR.
- * # <tt>||</tt> -- conditional OR with short circuit.
- * # <tt>!</tt> -- negation.
- *
- * Additional round brackets can also be used to perform grouping.
- *
- * @author Xiang Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @version v1.0, last update on Fri Dec 24 21:38:49 EST 2004
- * @package System.I18N
- */
-class TChoiceFormat extends TTranslate
-{
- /**
- * @return float the numerical value.
- */
- public function getValue()
- {
- return $this->getViewState('Value','');
- }
-
- /**
- * Sets the numerical choice value
- * @param float the choice value
- */
- public function setValue($value)
- {
- $this->setViewState('Value',$value,'');
- }
-
- /**
- * Display the choosen translated string.
- * Overrides the parent method, also calls parent's renderBody to
- * translate.
- */
- protected function translateText($text, $subs)
- {
- $text = parent::translateText($text, $subs);
- $choice = new ChoiceFormat();
- $value = $this->getValue();
- $string = $choice->format($text, $value);
- if($string)
- return strtr($string, array('{Value}'=> $value));
- }
-}
-?>
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ * @package System.I18N
+ */
+
+ /**
+ * Get the ChoiceFormat class.
+ */
+Prado::using('System.I18N.core.ChoiceFormat');
+Prado::using('System.I18N.TTranslate');
+
+/**
+ * TChoiceFormat class.
+ *
+ * This component performs message/string choice translation. The translation
+ * source is set in the TGlobalization module. The following example
+ * demonstrates a simple 2 choice message translation.
+ * <code>
+ * <com:TChoiceFormat Value="1">[1] One Apple. |[2] Two Apples</com:TChoiceFormat>
+ * </code>
+ *
+ * The Choice has <b>Value</b> "1" (one), thus the translated string
+ * is "One Apple". If the <b>Value</b> is "2", then it will show
+ * "Two Apples".
+ *
+ * The message/string choices are separated by the pipe "|" followed
+ * by a set notation of the form
+ * # <tt>[1,2]</tt> -- accepts values between 1 and 2, inclusive.
+ * # <tt>(1,2)</tt> -- accepts values between 1 and 2, excluding 1 and 2.
+ * # <tt>{1,2,3,4}</tt> -- only values defined in the set are accepted.
+ * # <tt>[-Inf,0)</tt> -- accepts value greater or equal to negative infinity
+ * and strictly less than 0
+ * Any non-empty combinations of the delimiters of square and round brackets
+ * are acceptable.
+ *
+ * The string choosen for display depends on the <b>Value</b> property.
+ * The <b>Value</b> is evaluated for each set until the Value is found
+ * to belong to a particular set.
+ *
+ * Properties
+ * - <b>Value</b>, float,
+ * <br>Gets or sets the Value that determines which string choice to display.
+ * Since version 3.1.2 the following set notation is also possible.
+ *
+ * # <tt>{n: n % 10 > 1 && n % 10 < 5}</tt> -- matches numbers like 2, 3, 4, 22, 23, 24
+ *
+ * Where set is defined by the expression after <tt>n:</tt>. In particular, the expression
+ * accepts the following mathematical/logical operators to form a set of logical conditions
+ * on the value given by <tt>n</tt>:
+ * # <tt>&lt;</tt> -- less than.
+ * # <tt>&lt;=</tt> -- less than equals.
+ * # <tt>&gt;</tt> -- greater than.
+ * # <tt>&gt=</tt> -- greater than equals.
+ * # <tt>==</tt> -- of equal value.
+ * # <tt>%</tt> -- modulo, e.g., 1 % 10 equals 1, 11 % 10 equals 1.
+ * # <tt>-</tt> -- minus, negative.
+ * # <tt>+</tt> -- addition.
+ * # <tt>&amp;</tt> -- conditional AND.
+ * # <tt>&amp;&amp;</tt> -- condition AND with short circuit.
+ * # <tt>|</tt> -- conditional OR.
+ * # <tt>||</tt> -- conditional OR with short circuit.
+ * # <tt>!</tt> -- negation.
+ *
+ * Additional round brackets can also be used to perform grouping.
+ *
+ * @author Xiang Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @version v1.0, last update on Fri Dec 24 21:38:49 EST 2004
+ * @package System.I18N
+ */
+class TChoiceFormat extends TTranslate
+{
+ /**
+ * @return float the numerical value.
+ */
+ public function getValue()
+ {
+ return $this->getViewState('Value','');
+ }
+
+ /**
+ * Sets the numerical choice value
+ * @param float the choice value
+ */
+ public function setValue($value)
+ {
+ $this->setViewState('Value',$value,'');
+ }
+
+ /**
+ * Display the choosen translated string.
+ * Overrides the parent method, also calls parent's renderBody to
+ * translate.
+ */
+ protected function translateText($text, $subs)
+ {
+ $text = parent::translateText($text, $subs);
+ $choice = new ChoiceFormat();
+ $value = $this->getValue();
+ $string = $choice->format($text, $value);
+ if($string)
+ return strtr($string, array('{Value}'=> $value));
+ }
+}
+?>