Ejemplo n.º 1
0
 /**
  * Test that parent bundles are loaded.
  */
 public function testGetParentLocale()
 {
     $this->assertEquals(null, $this->parent->getParentLocale());
     $this->assertInstanceOf('Titon\\G11n\\Locale', $this->formats->getParentLocale());
     $this->assertInstanceOf('Titon\\G11n\\Locale', $this->inflections->getParentLocale());
     $this->assertInstanceOf('Titon\\G11n\\Locale', $this->validations->getParentLocale());
 }
Ejemplo n.º 2
0
 /**
  * Return the parent locale if it exists.
  *
  * @uses Titon\G11n\Locale
  *
  * @return \Titon\G11n\Locale
  */
 public function getParentLocale()
 {
     if ($this->_parent) {
         return $this->_parent;
     }
     if (!$this->hasConfig('parent')) {
         return null;
     }
     $parent = new Locale($this->getConfig('parent'));
     $parent->initialize();
     // Merge parent config
     $this->addConfig($this->allConfig() + $parent->allConfig());
     $this->_parent = $parent;
     return $parent;
 }
Ejemplo n.º 3
0
Archivo: G11n.php Proyecto: titon/g11n
 /**
  * Sets up the application with the defined locale key; the key will be formatted to a lowercase dashed URL friendly format.
  * The system will then attempt to load the locale resource bundle and finalize configuration settings.
  *
  * @param \Titon\G11n\Locale $locale
  * @return \Titon\G11n\Locale
  */
 public function addLocale(Locale $locale)
 {
     $key = self::canonicalize($locale->getCode());
     if (isset($this->_locales[$key])) {
         return $this->_locales[$key];
     }
     // Configure and initialize
     foreach ($this->getResourcePaths() as $domain => $paths) {
         $locale->addResourcePaths($domain, $paths);
     }
     $locale->initialize();
     // Set the locale
     $this->_locales[$key] = $locale;
     // Set the parent as well
     if ($parent = $locale->getParentLocale()) {
         $this->addLocale($parent);
     }
     // Set fallback if none defined
     if (!$this->_fallback) {
         $this->setFallback($key);
     }
     return $locale;
 }