Author: fabien
Date: 2010-05-19 14:19:44 +0200 (Wed, 19 May 2010)
New Revision: 29522
Added:
branches/1.3/test/unit/helper/I18NHelperTest.php
branches/1.4/test/unit/helper/I18NHelperTest.php
Modified:
branches/1.3/lib/helper/I18NHelper.php
branches/1.4/lib/helper/I18NHelper.php
Log:
[1.3, 1.4] fixed format_number_choice() (closes #8643)
Modified: branches/1.3/lib/helper/I18NHelper.php
===================================================================
--- branches/1.3/lib/helper/I18NHelper.php 2010-05-19 11:47:56 UTC (rev
29521)
+++ branches/1.3/lib/helper/I18NHelper.php 2010-05-19 12:19:44 UTC (rev
29522)
@@ -45,18 +45,13 @@
function format_number_choice($text, $args = array(), $number, $catalogue =
'messages')
{
- $translated = __($text, $args, $catalogue);
-
$choice = new sfChoiceFormat();
-
- $retval = $choice->format($translated, $number);
-
- if ($retval === false)
+ if (false === $retval = $choice->format($text, $number))
{
throw new sfException(sprintf('Unable to parse your choice "%s".',
$translated));
}
- return $retval;
+ return __($retval, $args, $catalogue);
}
function format_country($country_iso, $culture = null)
Added: branches/1.3/test/unit/helper/I18NHelperTest.php
===================================================================
--- branches/1.3/test/unit/helper/I18NHelperTest.php
(rev 0)
+++ branches/1.3/test/unit/helper/I18NHelperTest.php 2010-05-19 12:19:44 UTC
(rev 29522)
@@ -0,0 +1,19 @@
+<?php
+
+/*
+ * This file is part of the symfony package.
+ * (c) Fabien Potencier <[email protected]>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+require_once(dirname(__FILE__).'/../../bootstrap/unit.php');
+require_once(dirname(__FILE__).'/../../../lib/helper/I18NHelper.php');
+
+$t = new lime_test(2);
+
+// format_number_choice()
+$t->diag('format_number_choice()');
+$t->is(format_number_choice('[1]1|(1,+Inf]%foo%', array('%foo%' => '(1)'), 1),
'1', 'format_number_choice() format a string containing plural information');
+$t->is(format_number_choice('[1]1|(1,+Inf]%foo%', array('%foo%' => '(1)'), 2),
'(1)', 'format_number_choice() format a string containing plural information');
Modified: branches/1.4/lib/helper/I18NHelper.php
===================================================================
--- branches/1.4/lib/helper/I18NHelper.php 2010-05-19 11:47:56 UTC (rev
29521)
+++ branches/1.4/lib/helper/I18NHelper.php 2010-05-19 12:19:44 UTC (rev
29522)
@@ -45,18 +45,13 @@
function format_number_choice($text, $args = array(), $number, $catalogue =
'messages')
{
- $translated = __($text, $args, $catalogue);
-
$choice = new sfChoiceFormat();
-
- $retval = $choice->format($translated, $number);
-
- if ($retval === false)
+ if (false === $retval = $choice->format($text, $number))
{
throw new sfException(sprintf('Unable to parse your choice "%s".',
$translated));
}
- return $retval;
+ return __($retval, $args, $catalogue);
}
function format_country($country_iso, $culture = null)
Added: branches/1.4/test/unit/helper/I18NHelperTest.php
===================================================================
--- branches/1.4/test/unit/helper/I18NHelperTest.php
(rev 0)
+++ branches/1.4/test/unit/helper/I18NHelperTest.php 2010-05-19 12:19:44 UTC
(rev 29522)
@@ -0,0 +1,19 @@
+<?php
+
+/*
+ * This file is part of the symfony package.
+ * (c) Fabien Potencier <[email protected]>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+require_once(dirname(__FILE__).'/../../bootstrap/unit.php');
+require_once(dirname(__FILE__).'/../../../lib/helper/I18NHelper.php');
+
+$t = new lime_test(2);
+
+// format_number_choice()
+$t->diag('format_number_choice()');
+$t->is(format_number_choice('[1]1|(1,+Inf]%foo%', array('%foo%' => '(1)'), 1),
'1', 'format_number_choice() format a string containing plural information');
+$t->is(format_number_choice('[1]1|(1,+Inf]%foo%', array('%foo%' => '(1)'), 2),
'(1)', 'format_number_choice() format a string containing plural information');
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.