Author: Kris.Wallsmith
Date: 2010-03-23 13:58:20 +0100 (Tue, 23 Mar 2010)
New Revision: 28703

Modified:
   branches/1.3/lib/i18n/sfI18N.class.php
   branches/1.3/test/unit/i18n/sfI18NTest.php
   branches/1.4/lib/i18n/sfI18N.class.php
   branches/1.4/test/unit/i18n/sfI18NTest.php
Log:
[1.3, 1.4] fixed setting of culture in sfI18N constructor (closes #8444)

Modified: branches/1.3/lib/i18n/sfI18N.class.php
===================================================================
--- branches/1.3/lib/i18n/sfI18N.class.php      2010-03-23 12:02:01 UTC (rev 
28702)
+++ branches/1.3/lib/i18n/sfI18N.class.php      2010-03-23 12:58:20 UTC (rev 
28703)
@@ -61,7 +61,7 @@
 
     if (isset($options['culture']))
     {
-      $this->culture = $options['culture'];
+      $this->setCulture($options['culture']);
       unset($options['culture']);
     }
 

Modified: branches/1.3/test/unit/i18n/sfI18NTest.php
===================================================================
--- branches/1.3/test/unit/i18n/sfI18NTest.php  2010-03-23 12:02:01 UTC (rev 
28702)
+++ branches/1.3/test/unit/i18n/sfI18NTest.php  2010-03-23 12:58:20 UTC (rev 
28703)
@@ -10,7 +10,7 @@
 
 require_once(dirname(__FILE__).'/../../bootstrap/unit.php');
 
-$t = new lime_test(33);
+$t = new lime_test(34);
 
 class ProjectConfiguration extends sfProjectConfiguration
 {
@@ -34,6 +34,20 @@
 $dispatcher->notify(new sfEvent(null, 'user.change_culture', array('culture' 
=> 'fr')));
 $t->is($i18n->getCulture(), 'fr', '->initialize() connects to the 
user.change_culture event');
 
+// passing a "culture" option to initialize() should set PHP locale
+if (class_exists('Locale') && ($en = Locale::lookup(array('en-US'), 'en-US', 
true)) && ($fr = Locale::lookup(array('fr-FR'), 'fr-FR', true)))
+{
+  $i18n = new sfI18N($configuration, $cache, array('culture' => $fr));
+  $frLocale = localeconv();
+  $i18n = new sfI18N($configuration, $cache, array('culture' => $en));
+  $enLocale = localeconv();
+  $t->isnt(serialize($frLocale), serialize($enLocale), '->initialize() sets 
the PHP locale when a "culture" option is provided');
+}
+else
+{
+  $t->skip('Locale class or English and French locales are not installed');
+}
+
 // ->getCulture() ->setCulture()
 $t->diag('->getCulture() ->setCulture()');
 $i18n = new sfI18N($configuration, $cache);

Modified: branches/1.4/lib/i18n/sfI18N.class.php
===================================================================
--- branches/1.4/lib/i18n/sfI18N.class.php      2010-03-23 12:02:01 UTC (rev 
28702)
+++ branches/1.4/lib/i18n/sfI18N.class.php      2010-03-23 12:58:20 UTC (rev 
28703)
@@ -61,7 +61,7 @@
 
     if (isset($options['culture']))
     {
-      $this->culture = $options['culture'];
+      $this->setCulture($options['culture']);
       unset($options['culture']);
     }
 

Modified: branches/1.4/test/unit/i18n/sfI18NTest.php
===================================================================
--- branches/1.4/test/unit/i18n/sfI18NTest.php  2010-03-23 12:02:01 UTC (rev 
28702)
+++ branches/1.4/test/unit/i18n/sfI18NTest.php  2010-03-23 12:58:20 UTC (rev 
28703)
@@ -10,7 +10,7 @@
 
 require_once(dirname(__FILE__).'/../../bootstrap/unit.php');
 
-$t = new lime_test(33);
+$t = new lime_test(34);
 
 class ProjectConfiguration extends sfProjectConfiguration
 {
@@ -34,6 +34,20 @@
 $dispatcher->notify(new sfEvent(null, 'user.change_culture', array('culture' 
=> 'fr')));
 $t->is($i18n->getCulture(), 'fr', '->initialize() connects to the 
user.change_culture event');
 
+// passing a "culture" option to initialize() should set PHP locale
+if (class_exists('Locale') && ($en = Locale::lookup(array('en-US'), 'en-US', 
true)) && ($fr = Locale::lookup(array('fr-FR'), 'fr-FR', true)))
+{
+  $i18n = new sfI18N($configuration, $cache, array('culture' => $fr));
+  $frLocale = localeconv();
+  $i18n = new sfI18N($configuration, $cache, array('culture' => $en));
+  $enLocale = localeconv();
+  $t->isnt(serialize($frLocale), serialize($enLocale), '->initialize() sets 
the PHP locale when a "culture" option is provided');
+}
+else
+{
+  $t->skip('Locale class or English and French locales are not installed');
+}
+
 // ->getCulture() ->setCulture()
 $t->diag('->getCulture() ->setCulture()');
 $i18n = new sfI18N($configuration, $cache);

-- 
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.

Reply via email to