/** * Setup bundles for specific conditions. */ protected function setUp() { parent::setUp(); $this->parent = new Locale('ex'); $this->parent->initialize(); $this->formats = new Locale('ex_FM'); $this->formats->initialize(); $this->inflections = new Locale('ex_IN'); $this->inflections->initialize(); $this->validations = new Locale('ex_VA'); $this->validations->initialize(); }
/** * 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; }
/** * 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; }