Example #1
0
 /**
  * Set the right locale via context.
  *
  * @param GetResponseEvent $event
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     $request = $event->getRequest();
     if (!$request->hasPreviousSession()) {
         return;
     }
     $request->setLocale($this->localeContext->getCurrentLocale() ?: $this->localeContext->getDefaultLocale());
 }
Example #2
0
 function it_converts_locales_code_to_name(LocaleContextInterface $localeContext)
 {
     $localeContext->getCurrentLocale()->shouldBeCalled()->willReturn('en_US');
     $this->convertToName('fr_FR')->shouldReturn('French (France)');
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 public function getLocaleCode()
 {
     return $this->localeContext->getCurrentLocale();
 }
Example #4
0
 function it_gets_current_locale_code_from_context(LocaleContextInterface $localeContext)
 {
     $localeContext->getCurrentLocale()->willReturn('en_US');
     $this->getLocaleCode()->shouldReturn('en_US');
 }