예제 #1
0
 /**
  * Return a message string if it exists.
  *
  * @param string $key
  * @param array  $vars
  *
  * @return string
  */
 public function message($key, array $vars = array())
 {
     try {
         $translated = parent::message($key, $vars);
     } catch (OutOfRangeException $e) {
         if ($this->defaultLocale === null) {
             throw $e;
         }
         // fallback default locale
         $locale = $this->getConfig('locale');
         $this->setLocale($this->defaultLocale);
         $translated = parent::message($key, $vars);
         $this->setLocale($locale);
     }
     return $translated;
 }
예제 #2
0
 /**
  * @expectedException \Decoda\Exception\MissingLocaleException
  */
 public function testCustomConfigPath()
 {
     $decoda = new Decoda('', array('configPath' => '/some/fake/path'));
     $this->assertEquals('Spoiler', $decoda->message('spoiler'));
 }