예제 #1
0
 /**
  * Create the locale-service
  *
  * @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
  * @return \Zork\I18n\Locale\Locale
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     // Configure the locale
     $config = $serviceLocator->get('Configuration');
     $srvConfig = isset($config['locale']) ? $config['locale'] : array();
     return Locale::factory($srvConfig);
 }
예제 #2
0
 /**
  * Test accept from http
  */
 public function testAccesptFromHttp()
 {
     $locale = Locale::factory(array('default' => 'en', 'available' => array('en' => true, 'fr' => true, 'de' => true)));
     $this->assertEquals('en', $locale->acceptFromHttp(null));
     $this->assertEquals('fr', $locale->acceptFromHttp('fr'));
     $this->assertEquals('fr', $locale->acceptFromHttp('fr, *;q=0.1'));
     $this->assertEquals('fr', $locale->acceptFromHttp('fr, de;q=0.8, *;q=0.1'));
     $this->assertEquals('de', $locale->acceptFromHttp('fr;q=0.8, de, *;q=0.1'));
     $this->assertEquals('de', $locale->acceptFromHttp('hu-HU, de;q=0.8, *;q=0.1'));
     $this->assertEquals('de', $locale->acceptFromHttp('hu, de-DE;q=0.8, *;q=0.1'));
     $this->assertEquals('en', $locale->acceptFromHttp('hu, no;q=0.8, *;q=0.1'));
 }
예제 #3
0
 /**
  * This method is called before the first test of this test class is run.
  */
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     static::$helperCtorArgs = array(static::$locale = Locale::factory(array('default' => 'en', 'fallback' => 'en', 'available' => array('en' => true, 'en_US' => true))));
 }