Exemplo n.º 1
0
 /**
  * @param Request $request
  * @return Localizer
  * @throws NoAvailableLocalesException
  */
 public function getLocalizer(Request $request)
 {
     $availableLocales = $this->getAvailableLocales();
     $localizer = new Localizer($availableLocales, $this->getDefaultLocale($availableLocales));
     $localizer->setCurrentLocale($this->getCurrentLocaleStrategy()->getLocale($request));
     return $localizer;
 }
Exemplo n.º 2
0
 /**
  * @expectedException \horses\i18n\UnknownLocaleException
  */
 public function testSetCurrentLocaleUnknown()
 {
     $availableLocales = ['en', 'fr'];
     $defaultLocale = 'en';
     $localizer = new Localizer($availableLocales, $defaultLocale);
     $localizer->setCurrentLocale('foo');
 }
Exemplo n.º 3
0
 /**
  * @expectedException \horses\i18n\UnknownLocaleException
  */
 public function testTranslateUnknownLocale()
 {
     $this->localizer->expects($this->any())->method('getCurrentLocale')->will($this->returnValue('FOO'));
     $this->translator->translate('key1');
 }